lorekeeper 2.0.0 → 2.1.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: 86c3b19f169215f175bd0770ab165fb68203e9aed3e8bd0cb01102d7c758bb67
4
- data.tar.gz: 6f9a9302433dec14b3a501b49bfd3610ad3904ab948d0c39390af539f55b3a7e
3
+ metadata.gz: b8a5d046cc9e67c4efda44b74aa45acd384a49d58b1ea710799ff072de7b0316
4
+ data.tar.gz: c095a976184d6456d2605fdebc25ed20e31b992672e066b892b08be201fe70c8
5
5
  SHA512:
6
- metadata.gz: 62de8ba1553a553cc212bbb3d8a84e2fc8bb98902c3867dfebda2fe7e7f41a716b60d0be81cd281210fef9041972a40757ec9aed724dc468fa775471b62637dc
7
- data.tar.gz: '0186d14f8511e2aa0489dba5a98794477e1c7f9f7220af7a3f884947084a0c5d60195d434ed4b406fd3bf252ee5a4a9b3aac3b3a89f6fc832f01c1ddf31fd305'
6
+ metadata.gz: 76c142c27abbae12ec4e5bde2262ea79f962f0e5aa9ac6074c04fdf7b84cdc3d5c62cdfdaae45874589d53300de2ddc961657562d9abffbbec8501575ae9f2d6
7
+ data.tar.gz: 3e86217440ba8269f05c1a1ec44bc4262067a9608ee7caab4a35cfc222a8870a2e7bfbb51dd275ea42ee7169cc033d79ee692dd469f5e16b9a21ae04af348803
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ # 2.1.0
2
+ * Modify SimpleLogger to properly log exceptions with named parameters
3
+
1
4
  # 2.0.0
2
5
  * Set `mode: :compat` in Oj.dump to stringify keys
3
6
  * Support Ruby 3.1
@@ -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
- def exception(exception, custom_message = nil, custom_data = nil, level = :error)
47
- log_level = METHOD_SEVERITY_MAP[level] || ERROR
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
- backtrace = exception.backtrace || []
51
- message = custom_message || exception.message
52
- log_data(log_level, "#{exception.class}: #{exception.message}; #{message}, data: #{backtrace.join("\n")}")
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} #{custom_message}", custom_data)
70
+ error_with_data("#{exception.class}: #{exception.inspect} #{param_message}", param_data)
56
71
  end
57
72
  end
58
73
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Lorekeeper
4
- VERSION = '2.0.0'
4
+ VERSION = '2.1.0'
5
5
  end
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.0.0
4
+ version: 2.1.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-03 00:00:00.000000000 Z
11
+ date: 2022-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oj