lorekeeper 1.12.0 → 2.2.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/build.yml +1 -1
- data/.rubocop.yml +4 -0
- data/CHANGELOG.md +12 -0
- data/lib/lorekeeper/fast_logger.rb +1 -1
- data/lib/lorekeeper/json_logger.rb +2 -2
- data/lib/lorekeeper/multi_logger.rb +25 -8
- data/lib/lorekeeper/simple_logger.rb +22 -7
- data/lib/lorekeeper/version.rb +1 -1
- data/lorekeeper.gemspec +2 -2
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94314cd2617d7cfc5478a07242e7b006aba90b8f0736e3760c0c143b6149a867
|
4
|
+
data.tar.gz: 6a959aa730667a1d39b3aeddfd36f0fd666dd5e2851401af157cba7a6db5b407
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 381adbf920503525d566c0c51127f0826feaf20eb644c3cfae82a63b8f601d8c8c7a61f4bcb536589656908fe08758ba2e0e21cfcf643b7bb3896b62dd5d6a01
|
7
|
+
data.tar.gz: c293f3b312e22b49632a3494f70e7593eff119024826c10d78ab127b9061c04cd2caac95f5511866f7bac8f65cc0cdb2fe90210d9cec352d11aafa799b0d481e
|
data/.github/workflows/build.yml
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,2 +1,6 @@
|
|
1
1
|
Metrics/LineLength:
|
2
2
|
Max: 120
|
3
|
+
# https://github.com/rubocop/rubocop/blob/20990ed3831589c0d9f202107b1b580ead8ef2c5/lib/rubocop/cop/style/single_line_methods.rb#L11
|
4
|
+
# TODO: add "EnforcedStyle: allow_single_line" once all rubys are > 3.0 to autocorrect all single-line methods to endless
|
5
|
+
Style/SingleLineMethods:
|
6
|
+
Enabled: false
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
# 2.2.0
|
2
|
+
* Remove metaprogramming from MultiLogger
|
3
|
+
* Drop support for Ruby < 2.7.0
|
4
|
+
|
5
|
+
# 2.1.0
|
6
|
+
* Modify SimpleLogger to properly log exceptions with named parameters
|
7
|
+
|
8
|
+
# 2.0.0
|
9
|
+
* Set `mode: :compat` in Oj.dump to stringify keys
|
10
|
+
* Support Ruby 3.1
|
11
|
+
* Drop support for Ruby < 2.5.0
|
12
|
+
|
1
13
|
# 1.12.0
|
2
14
|
* Remove ZipkinTracer information from stacktrace output
|
3
15
|
* Move CI to GitHub Actions
|
@@ -56,7 +56,7 @@ module Lorekeeper
|
|
56
56
|
# This is part of the standard Logger API, we need this to be compatible
|
57
57
|
def add(severity, message_param = nil, progname = nil, &block)
|
58
58
|
return true if severity < @level
|
59
|
-
message =
|
59
|
+
message = (block && block.call) || message_param || progname
|
60
60
|
log_data(severity, message.freeze)
|
61
61
|
end
|
62
62
|
|
@@ -8,7 +8,7 @@ module Lorekeeper
|
|
8
8
|
class JSONLogger < FastLogger
|
9
9
|
def initialize(file)
|
10
10
|
reset_state
|
11
|
-
@base_fields = {
|
11
|
+
@base_fields = { TIMESTAMP => '', MESSAGE => '', LEVEL => '' }
|
12
12
|
@backtrace_cleaner = set_backtrace_cleaner
|
13
13
|
super(file)
|
14
14
|
end
|
@@ -148,7 +148,7 @@ module Lorekeeper
|
|
148
148
|
fields_to_log[TIMESTAMP] = Time.now.utc.strftime(DATE_FORMAT)
|
149
149
|
fields_to_log[LEVEL] = SEVERITY_NAMES_MAP[severity]
|
150
150
|
|
151
|
-
@iodevice.write(Oj.dump(fields_to_log) << "\n")
|
151
|
+
@iodevice.write(Oj.dump(fields_to_log, mode: :compat, cache_keys: true, cache_str: 5) << "\n")
|
152
152
|
end
|
153
153
|
end
|
154
154
|
end
|
@@ -16,17 +16,34 @@ module Lorekeeper
|
|
16
16
|
"Lorekeeper multilogger, loggers: #{@loggers.map(&:inspect)}"
|
17
17
|
end
|
18
18
|
|
19
|
-
|
20
|
-
def
|
19
|
+
# Define all common logging methods within Multilogger to avoid NoMethodError
|
20
|
+
def debug(*args, &block); call_loggers(:debug, *args, &block); end
|
21
|
+
|
22
|
+
def debug_with_data(*args, &block); call_loggers(:debug, *args, &block); end
|
23
|
+
|
24
|
+
def info(*args, &block); call_loggers(:info, *args, &block); end
|
25
|
+
|
26
|
+
def info_with_data(*args, &block); call_loggers(:info, *args, &block); end
|
27
|
+
|
28
|
+
def warn(*args, &block); call_loggers(:warn, *args, &block); end
|
29
|
+
|
30
|
+
def warn_with_data(*args, &block); call_loggers(:warn, *args, &block); end
|
31
|
+
|
32
|
+
def error(*args, &block); call_loggers(:error, *args, &block); end
|
33
|
+
|
34
|
+
def error_with_data(*args, &block); call_loggers(:error, *args, &block); end
|
35
|
+
|
36
|
+
def fatal(*args, &block); call_loggers(:fatal, *args, &block); end
|
37
|
+
|
38
|
+
def fatal_with_data(*args, &block); call_loggers(:fatal, *args, &block); end
|
39
|
+
|
40
|
+
def write(*args); call_loggers(:write, *args); end
|
41
|
+
|
42
|
+
def respond_to?(method, all_included: false)
|
21
43
|
@loggers.all? { |logger| logger.respond_to?(method, all_included) }
|
22
44
|
end
|
23
|
-
else
|
24
|
-
def respond_to?(method)
|
25
|
-
@loggers.all? { |logger| logger.respond_to?(method) }
|
26
|
-
end
|
27
|
-
end
|
28
45
|
|
29
|
-
def
|
46
|
+
def call_loggers(method, *args, &block)
|
30
47
|
result = @loggers.map do |logger|
|
31
48
|
logger.public_send(method, *args, &block) if logger.respond_to?(method)
|
32
49
|
end
|
@@ -28,7 +28,7 @@ module Lorekeeper
|
|
28
28
|
# \e[colorm sets a color \e[0m resets all properties
|
29
29
|
def log_data(severity, message)
|
30
30
|
color = SEVERITY_TO_COLOR_MAP[severity]
|
31
|
-
@iodevice.write("\e[#{color}m#{message}\e[0m\n")
|
31
|
+
@iodevice.write("\e[#{color}m#{message.gsub('\n', "\n").gsub('\t', "\t")}\e[0m\n")
|
32
32
|
end
|
33
33
|
|
34
34
|
def inspect
|
@@ -43,16 +43,31 @@ module Lorekeeper
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
-
|
47
|
-
|
46
|
+
# To not raise NoMethodError for the methods defined in JSONLogger
|
47
|
+
def current_fields(*); end
|
48
|
+
def state(*); end
|
49
|
+
def add_thread_unsafe_fields(*); end
|
50
|
+
def remove_thread_unsafe_fields(*); end
|
51
|
+
def add_fields(*); end
|
52
|
+
def remove_fields(*); end
|
53
|
+
|
54
|
+
def exception(exception, custom_message = nil, custom_data = nil, custom_level = :error,
|
55
|
+
message: nil, data: nil, level: nil)
|
56
|
+
|
57
|
+
param_level = level || custom_level
|
58
|
+
param_data = data || custom_data
|
59
|
+
param_message = message || custom_message
|
60
|
+
|
61
|
+
log_level = METHOD_SEVERITY_MAP[param_level] || ERROR
|
48
62
|
|
49
63
|
if exception.is_a?(Exception)
|
50
|
-
|
51
|
-
|
52
|
-
|
64
|
+
message = param_message || exception.message
|
65
|
+
backtrace = "\n\nstack:\n#{exception.backtrace.join("\n")}" if exception.backtrace
|
66
|
+
data = "\n\ndata:\n#{param_data}" if param_data
|
67
|
+
log_data(log_level, "#{exception.class}: #{exception.message}; #{message} #{backtrace} #{data}")
|
53
68
|
else
|
54
69
|
log_data(METHOD_SEVERITY_MAP[:warn], 'Logger exception called without exception class.')
|
55
|
-
error_with_data("#{exception.class}: #{exception.inspect} #{
|
70
|
+
error_with_data("#{exception.class}: #{exception.inspect} #{param_message}", param_data)
|
56
71
|
end
|
57
72
|
end
|
58
73
|
end
|
data/lib/lorekeeper/version.rb
CHANGED
data/lorekeeper.gemspec
CHANGED
@@ -20,9 +20,9 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
21
|
spec.require_paths = ['lib']
|
22
22
|
|
23
|
-
spec.required_ruby_version = '>= 2.
|
23
|
+
spec.required_ruby_version = '>= 2.7.0'
|
24
24
|
|
25
|
-
spec.add_dependency 'oj', '>= 3.
|
25
|
+
spec.add_dependency 'oj', '>= 3.12', '< 4.0'
|
26
26
|
|
27
27
|
spec.add_development_dependency 'activesupport', '>= 4.0'
|
28
28
|
spec.add_development_dependency 'bundler', '>= 1.16', '< 3.0'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lorekeeper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jordi Polo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oj
|
@@ -16,7 +16,7 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '3.
|
19
|
+
version: '3.12'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: '4.0'
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '3.
|
29
|
+
version: '3.12'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '4.0'
|
@@ -213,7 +213,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
213
213
|
requirements:
|
214
214
|
- - ">="
|
215
215
|
- !ruby/object:Gem::Version
|
216
|
-
version: 2.
|
216
|
+
version: 2.7.0
|
217
217
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
218
218
|
requirements:
|
219
219
|
- - ">="
|