loog 0.7.2 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -4
- data/README.md +13 -0
- data/lib/loog/colorful.rb +59 -0
- data/loog.gemspec +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3e01b62407f7956b6b405542638726dc614ddb98b2105a3e347dcd723759fdf6
|
|
4
|
+
data.tar.gz: 40aea8035dd1b5594a0cea9d498d67009837f8e3f865cb611b75f3228ce8386f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d5ff6f181106c093af764f988141787be5f8de1b6f6b6f0699eea1629b546c018c1ca1f8efd40c94ff19a87199deaeadbd9eb02644f22ad03c145d98c7f3672a
|
|
7
|
+
data.tar.gz: 5e6032b3627737bf34e7d80f631799bb36c7ead4dd6e29bbd5b090a5c94c0c13bd6ce235678256646fc12a4f39ea21a3eb1b372bfa6f49c8478474a45f9bf720
|
data/Gemfile.lock
CHANGED
|
@@ -15,7 +15,7 @@ GEM
|
|
|
15
15
|
docile (1.4.1)
|
|
16
16
|
ellipsized (0.3.0)
|
|
17
17
|
erb (6.0.1)
|
|
18
|
-
json (2.18.
|
|
18
|
+
json (2.18.1)
|
|
19
19
|
language_server-protocol (3.17.0.5)
|
|
20
20
|
lint_roller (1.1.0)
|
|
21
21
|
logger (1.7.0)
|
|
@@ -30,7 +30,7 @@ GEM
|
|
|
30
30
|
parser (3.3.10.1)
|
|
31
31
|
ast (~> 2.4.1)
|
|
32
32
|
racc
|
|
33
|
-
prism (1.
|
|
33
|
+
prism (1.9.0)
|
|
34
34
|
psych (5.3.1)
|
|
35
35
|
date
|
|
36
36
|
stringio
|
|
@@ -43,7 +43,7 @@ GEM
|
|
|
43
43
|
tsort
|
|
44
44
|
regexp_parser (2.11.3)
|
|
45
45
|
rexml (3.4.4)
|
|
46
|
-
rubocop (1.
|
|
46
|
+
rubocop (1.84.1)
|
|
47
47
|
json (~> 2.3)
|
|
48
48
|
language_server-protocol (~> 3.17.0.2)
|
|
49
49
|
lint_roller (~> 1.1.0)
|
|
@@ -51,7 +51,7 @@ GEM
|
|
|
51
51
|
parser (>= 3.3.0.2)
|
|
52
52
|
rainbow (>= 2.2.2, < 4.0)
|
|
53
53
|
regexp_parser (>= 2.9.3, < 3.0)
|
|
54
|
-
rubocop-ast (>= 1.
|
|
54
|
+
rubocop-ast (>= 1.49.0, < 2.0)
|
|
55
55
|
ruby-progressbar (~> 1.7)
|
|
56
56
|
unicode-display_width (>= 2.4.0, < 4.0)
|
|
57
57
|
rubocop-ast (1.49.0)
|
data/README.md
CHANGED
|
@@ -57,6 +57,19 @@ loog.info('This is a very long message that will be truncated')
|
|
|
57
57
|
# prints: "This is...truncated"
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
+
You can add ANSI colors to log messages with `Loog::Colorful`,
|
|
61
|
+
which prints debug messages in dark gray, warnings in orange,
|
|
62
|
+
and errors in red:
|
|
63
|
+
|
|
64
|
+
```ruby
|
|
65
|
+
require 'loog'
|
|
66
|
+
require 'loog/colorful'
|
|
67
|
+
loog = Loog::Colorful.new(Loog::VERBOSE)
|
|
68
|
+
loog.debug('This is dark gray')
|
|
69
|
+
loog.warn('This is orange')
|
|
70
|
+
loog.error('This is red')
|
|
71
|
+
```
|
|
72
|
+
|
|
60
73
|
## How to contribute
|
|
61
74
|
|
|
62
75
|
Read
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2018-2026 Yegor Bugayenko
|
|
4
|
+
# SPDX-License-Identifier: MIT
|
|
5
|
+
|
|
6
|
+
require_relative '../loog'
|
|
7
|
+
|
|
8
|
+
# Log decorator that adds ANSI colors to messages by severity:
|
|
9
|
+
#
|
|
10
|
+
# require 'loog'
|
|
11
|
+
# require 'loog/colorful'
|
|
12
|
+
# log = Loog::Colorful.new(Loog::VERBOSE)
|
|
13
|
+
# log.debug('This will be dark gray')
|
|
14
|
+
# log.error('This will be red')
|
|
15
|
+
#
|
|
16
|
+
# Debug messages are printed in dark gray, warnings in orange,
|
|
17
|
+
# and error messages in red. Info messages pass through unchanged.
|
|
18
|
+
#
|
|
19
|
+
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
20
|
+
# Copyright:: Copyright (c) 2018-2026 Yegor Bugayenko
|
|
21
|
+
# License:: MIT
|
|
22
|
+
class Loog::Colorful
|
|
23
|
+
# Makes an instance.
|
|
24
|
+
def initialize(log)
|
|
25
|
+
@log = log
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def debug(msg)
|
|
29
|
+
@log.debug("\e[90m#{msg}\e[0m")
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def debug?
|
|
33
|
+
@log.debug?
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def info(msg)
|
|
37
|
+
@log.info(msg)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def info?
|
|
41
|
+
@log.info?
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def warn(msg)
|
|
45
|
+
@log.warn("\e[33m#{msg}\e[0m")
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def warn?
|
|
49
|
+
@log.warn?
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def error(msg)
|
|
53
|
+
@log.error("\e[31m#{msg}\e[0m")
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def error?
|
|
57
|
+
@log.error?
|
|
58
|
+
end
|
|
59
|
+
end
|
data/loog.gemspec
CHANGED
|
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
|
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
|
|
9
9
|
s.required_ruby_version = '>=2.3'
|
|
10
10
|
s.name = 'loog'
|
|
11
|
-
s.version = '0.
|
|
11
|
+
s.version = '0.8.0'
|
|
12
12
|
s.license = 'MIT'
|
|
13
13
|
s.summary = 'Object-oriented logging wrapper'
|
|
14
14
|
s.description = 'Object-oriented wrapper for Ruby default logging facility'
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: loog
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Yegor Bugayenko
|
|
@@ -52,6 +52,7 @@ files:
|
|
|
52
52
|
- REUSE.toml
|
|
53
53
|
- Rakefile
|
|
54
54
|
- lib/loog.rb
|
|
55
|
+
- lib/loog/colorful.rb
|
|
55
56
|
- lib/loog/ellipsized.rb
|
|
56
57
|
- lib/loog/tee.rb
|
|
57
58
|
- logo.svg
|