loog 0.3.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +1 -1
- data/.rultor.yml +1 -1
- data/Gemfile +7 -0
- data/README.md +3 -2
- data/lib/loog.rb +23 -1
- data/loog.gemspec +1 -7
- data/test/test__helper.rb +0 -4
- data/test/test_loog.rb +15 -0
- metadata +4 -88
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cea04c3238de13e46a75055d845151bc907c33e7f50c34a48574f66f7cf27f07
|
4
|
+
data.tar.gz: f6024f8ed1224ae10c09e280d9948ab5a0a1d04e92ac58aed1f198b4beb934a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bf3a37ccbcaa2f9569622329dbd1134851571151fb56701a1f5bd151deec3e514f2120a39f43892b629450b4a5fb7574dcd87526d0ff65d5bc093c3524b5da5
|
7
|
+
data.tar.gz: 8994f5542b0a63ed5f7526e47884e30163df2f081a7c0524cb746294af7c2f5d68b16d4befe55ab88fd5144e60d86329522424a8567c17682e33ab280fbf14a7
|
data/.github/workflows/rake.yml
CHANGED
data/.rultor.yml
CHANGED
data/Gemfile
CHANGED
@@ -22,3 +22,10 @@
|
|
22
22
|
|
23
23
|
source 'https://rubygems.org'
|
24
24
|
gemspec
|
25
|
+
|
26
|
+
gem 'minitest', '5.19.0', require: false
|
27
|
+
gem 'rake', '13.0.6', require: false
|
28
|
+
gem 'rdoc', '6.5.0', require: false
|
29
|
+
gem 'rubocop', '1.54.2', require: false
|
30
|
+
gem 'rubocop-rspec', '2.22.0', require: false
|
31
|
+
gem 'simplecov', '0.22.0', require: false
|
data/README.md
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
<img src="/logo.svg" width="64px" height="64px"/>
|
2
2
|
|
3
|
-
[![Managed by Zerocracy](https://www.0crat.com/badge/C3RFVLU72.svg)](https://www.0crat.com/p/C3RFVLU72)
|
4
3
|
[![EO principles respected here](https://www.elegantobjects.org/badge.svg)](https://www.elegantobjects.org)
|
5
4
|
[![DevOps By Rultor.com](http://www.rultor.com/b/yegor256/loog)](http://www.rultor.com/p/yegor256/loog)
|
6
5
|
[![We recommend RubyMine](https://www.elegantobjects.org/rubymine.svg)](https://www.jetbrains.com/ruby/)
|
@@ -32,7 +31,9 @@ The gem is basically a provider of a few pre-configured loggers, which
|
|
32
31
|
you can use for production (`Loog::REGULAR`) or for testing (`Loog::VERBOSE`).
|
33
32
|
You can also shut it up with `Loog::NULL`.
|
34
33
|
|
35
|
-
|
34
|
+
There is also `Logger::Buffer` class that you can use for testing.
|
35
|
+
It accumulates all log calls and then returns the entire output
|
36
|
+
through the `to_s()` method.
|
36
37
|
|
37
38
|
## How to contribute
|
38
39
|
|
data/lib/loog.rb
CHANGED
@@ -46,7 +46,7 @@ module Loog
|
|
46
46
|
when 'DEBUG'
|
47
47
|
prefix = 'D: '
|
48
48
|
end
|
49
|
-
"#{prefix}#{msg.to_s.rstrip.gsub(
|
49
|
+
"#{prefix}#{msg.to_s.rstrip.gsub("\n", "\n#{' ' * prefix.length}")}\n"
|
50
50
|
end
|
51
51
|
|
52
52
|
# Short formatter
|
@@ -86,4 +86,26 @@ module Loog
|
|
86
86
|
ERRORS.level = Logger::ERROR
|
87
87
|
ERRORS.formatter = COMPACT
|
88
88
|
ERRORS.freeze
|
89
|
+
|
90
|
+
# Accumulator of everything. This class may be used
|
91
|
+
# for testing, when it's necessary to accumulate all log
|
92
|
+
# messages in one place and then "assert" the presence
|
93
|
+
# of certain strings inside them.
|
94
|
+
class Buffer < Logger
|
95
|
+
def initialize(formatter: Loog::SHORT)
|
96
|
+
super(
|
97
|
+
$stdout,
|
98
|
+
level: Logger::DEBUG,
|
99
|
+
formatter: proc do |severity, time, target, msg|
|
100
|
+
@lines.push(formatter.call(severity, time, target, msg))
|
101
|
+
''
|
102
|
+
end
|
103
|
+
)
|
104
|
+
@lines = []
|
105
|
+
end
|
106
|
+
|
107
|
+
def to_s
|
108
|
+
@lines.join("\n")
|
109
|
+
end
|
110
|
+
end
|
89
111
|
end
|
data/loog.gemspec
CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |s|
|
|
27
27
|
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
|
28
28
|
s.required_ruby_version = '>=2.3'
|
29
29
|
s.name = 'loog'
|
30
|
-
s.version = '0.
|
30
|
+
s.version = '0.5.0'
|
31
31
|
s.license = 'MIT'
|
32
32
|
s.summary = 'Object-oriented logging wrapper'
|
33
33
|
s.description = 'Object-oriented wrapper for Ruby default logging facility'
|
@@ -37,11 +37,5 @@ Gem::Specification.new do |s|
|
|
37
37
|
s.files = `git ls-files`.split($RS)
|
38
38
|
s.rdoc_options = ['--charset=UTF-8']
|
39
39
|
s.extra_rdoc_files = ['README.md']
|
40
|
-
s.add_development_dependency 'codecov', '0.6.0'
|
41
|
-
s.add_development_dependency 'minitest', '5.18.0'
|
42
|
-
s.add_development_dependency 'rake', '13.0.6'
|
43
|
-
s.add_development_dependency 'rdoc', '6.5.0'
|
44
|
-
s.add_development_dependency 'rubocop', '1.48.1'
|
45
|
-
s.add_development_dependency 'rubocop-rspec', '2.19.0'
|
46
40
|
s.metadata['rubygems_mfa_required'] = 'true'
|
47
41
|
end
|
data/test/test__helper.rb
CHANGED
data/test/test_loog.rb
CHANGED
@@ -37,4 +37,19 @@ class LoogTest < Minitest::Test
|
|
37
37
|
def test_null_logging
|
38
38
|
Loog::NULL.info('Should not be visible')
|
39
39
|
end
|
40
|
+
|
41
|
+
def test_buffering
|
42
|
+
b = Loog::Buffer.new(formatter: Loog::FULL)
|
43
|
+
b.debug('Hello, world!')
|
44
|
+
stdout = b.to_s
|
45
|
+
assert(stdout.include?('Hello'))
|
46
|
+
assert(stdout.include?('DEBUG'))
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_quiet_buffering
|
50
|
+
b = Loog::Buffer.new
|
51
|
+
msg = 'Hey, друг!'
|
52
|
+
b.info(msg)
|
53
|
+
assert_equal(b.to_s, "#{msg}\n")
|
54
|
+
end
|
40
55
|
end
|
metadata
CHANGED
@@ -1,99 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: loog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yegor Bugayenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: codecov
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - '='
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 0.6.0
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - '='
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: 0.6.0
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: minitest
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - '='
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 5.18.0
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - '='
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: 5.18.0
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rake
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - '='
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 13.0.6
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - '='
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: 13.0.6
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rdoc
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - '='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 6.5.0
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - '='
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: 6.5.0
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: rubocop
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - '='
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: 1.48.1
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - '='
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: 1.48.1
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: rubocop-rspec
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - '='
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: 2.19.0
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - '='
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: 2.19.0
|
11
|
+
date: 2023-07-28 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
97
13
|
description: Object-oriented wrapper for Ruby default logging facility
|
98
14
|
email: yegor256@gmail.com
|
99
15
|
executables: []
|
@@ -147,7 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
147
63
|
- !ruby/object:Gem::Version
|
148
64
|
version: '0'
|
149
65
|
requirements: []
|
150
|
-
rubygems_version: 3.
|
66
|
+
rubygems_version: 3.2.15
|
151
67
|
signing_key:
|
152
68
|
specification_version: 4
|
153
69
|
summary: Object-oriented logging wrapper
|