lorekeeper 2.1.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b8a5d046cc9e67c4efda44b74aa45acd384a49d58b1ea710799ff072de7b0316
4
- data.tar.gz: c095a976184d6456d2605fdebc25ed20e31b992672e066b892b08be201fe70c8
3
+ metadata.gz: 1b323055eadcf9d776721dbf722fc84a3fa9c17d43fc2e1874d084eb4fab848a
4
+ data.tar.gz: 50329808d64339ccb223eeb8d9e44f3eeeccfbdf8e32bfb746d26db31d5f7123
5
5
  SHA512:
6
- metadata.gz: 76c142c27abbae12ec4e5bde2262ea79f962f0e5aa9ac6074c04fdf7b84cdc3d5c62cdfdaae45874589d53300de2ddc961657562d9abffbbec8501575ae9f2d6
7
- data.tar.gz: 3e86217440ba8269f05c1a1ec44bc4262067a9608ee7caab4a35cfc222a8870a2e7bfbb51dd275ea42ee7169cc033d79ee692dd469f5e16b9a21ae04af348803
6
+ metadata.gz: '08252a6d8b16fdf22554adb3b2c7b19b4d6c5d36fb154759004a178407b60a82affd2f4950b3b942955013d20464f8ec41d2222f75cc05349fd042e31a728ee5'
7
+ data.tar.gz: c46a95ddabda346971ecdda9039a1b98a0c816be963e5024cdac49461327f557d12d3842345979b54dff8771aca1f2e0b6e5b2046f91ce00d9a889f03f9d5408
@@ -14,7 +14,7 @@ jobs:
14
14
  runs-on: ubuntu-latest
15
15
  strategy:
16
16
  matrix:
17
- ruby-version: ['2.5', '2.6', '2.7', '3.0', '3.1']
17
+ ruby-version: ['2.7', '3.0', '3.1']
18
18
 
19
19
  steps:
20
20
  - uses: actions/checkout@v2
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,13 @@
1
+ # 2.3.0
2
+ * Add `#write` method support to all loggers
3
+
4
+ # 2.2.1
5
+ * Fix MultiLogger to not raise NoMethodError
6
+
7
+ # 2.2.0
8
+ * Remove metaprogramming from MultiLogger
9
+ * Drop support for Ruby < 2.7.0
10
+
1
11
  # 2.1.0
2
12
  * Modify SimpleLogger to properly log exceptions with named parameters
3
13
 
@@ -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 = message_param || (block && block.call) || progname
59
+ message = (block && block.call) || message_param || progname
60
60
  log_data(severity, message.freeze)
61
61
  end
62
62
 
@@ -75,6 +75,10 @@ module Lorekeeper
75
75
 
76
76
  # inherited classes probably want to reimplement this
77
77
  def log_data(_severity, message)
78
+ write(message)
79
+ end
80
+
81
+ def write(message)
78
82
  @iodevice.write(message)
79
83
  end
80
84
 
@@ -8,7 +8,7 @@ module Lorekeeper
8
8
  class JSONLogger < FastLogger
9
9
  def initialize(file)
10
10
  reset_state
11
- @base_fields = { MESSAGE => '', TIMESTAMP => '', LEVEL => '' }
11
+ @base_fields = { TIMESTAMP => '', MESSAGE => '', LEVEL => '' }
12
12
  @backtrace_cleaner = set_backtrace_cleaner
13
13
  super(file)
14
14
  end
@@ -94,6 +94,10 @@ module Lorekeeper
94
94
  "Lorekeeper JSON logger. IO: #{@file.inspect}"
95
95
  end
96
96
 
97
+ def write(message)
98
+ super(Oj.dump(message, mode: :compat, cache_keys: true, cache_str: 5) << "\n")
99
+ end
100
+
97
101
  private
98
102
 
99
103
  # Some instrumentation libraries pollute the stacktrace and create a large output which may
@@ -148,7 +152,7 @@ module Lorekeeper
148
152
  fields_to_log[TIMESTAMP] = Time.now.utc.strftime(DATE_FORMAT)
149
153
  fields_to_log[LEVEL] = SEVERITY_NAMES_MAP[severity]
150
154
 
151
- @iodevice.write(Oj.dump(fields_to_log, mode: :compat, cache_keys: true, cache_str: 5) << "\n")
155
+ write(fields_to_log)
152
156
  end
153
157
  end
154
158
  end
@@ -16,17 +16,34 @@ module Lorekeeper
16
16
  "Lorekeeper multilogger, loggers: #{@loggers.map(&:inspect)}"
17
17
  end
18
18
 
19
- if RUBY_VERSION > "2.6"
20
- def respond_to?(method, all_included = false)
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 method_missing(method, *args, &block)
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
@@ -34,5 +51,9 @@ end
34
51
  # Then hope for the best taking the first value
35
52
  result.compact.uniq.first
36
53
  end
54
+
55
+ def method_missing(method, *args, &block)
56
+ call_loggers(method, *args, &block)
57
+ end
37
58
  end
38
59
  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.gsub('\n', "\n").gsub('\t', "\t")}\e[0m\n")
31
+ write("\e[#{color}m#{message.gsub('\n', "\n").gsub('\t', "\t")}\e[0m\n")
32
32
  end
33
33
 
34
34
  def inspect
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Lorekeeper
4
- VERSION = '2.1.0'
4
+ VERSION = '2.3.0'
5
5
  end
data/lorekeeper.gemspec CHANGED
@@ -20,7 +20,7 @@ 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.5.0'
23
+ spec.required_ruby_version = '>= 2.7.0'
24
24
 
25
25
  spec.add_dependency 'oj', '>= 3.12', '< 4.0'
26
26
 
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: 2.1.0
4
+ version: 2.3.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: 2022-05-23 00:00:00.000000000 Z
11
+ date: 2022-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oj
@@ -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.5.0
216
+ version: 2.7.0
217
217
  required_rubygems_version: !ruby/object:Gem::Requirement
218
218
  requirements:
219
219
  - - ">="