startback 0.11.3 → 0.11.4

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: 83733eb966d9d9679a15840dfa76f717aacaacc5c3eb417c6bf518a3eea1e3cd
4
- data.tar.gz: f13815553606f4567e136beb86fc19a066720a3bcdf520c3781c12a732808f47
3
+ metadata.gz: 929e1ab2d7ab916eadc828ecf2d1695c14c9a43d117198457e03c70c8b479ba4
4
+ data.tar.gz: 2f3d212acd31e00b1910aca3c3c1154a5e8a130962aeb002c184c6a70da17ab2
5
5
  SHA512:
6
- metadata.gz: 0a2c80c7c65fbe845784a6ee1326bed2a1d6f89eed591580800e1ee9f403fea24b61e92b1f1ad13356f612308a30c6ecc17f6c6a16fadb9c82ae6dec61b68d31
7
- data.tar.gz: 18dc6c715ba6ed1715c6d838421476959942611a120ba04eed7a72d40d505e53c60b64ecbf4e877d2a99d2c46300cfa8e83f6cb70960bb72ad599d7d5802509f
6
+ metadata.gz: 90d448f505406727db9cd5c1db1d2fdb14b5df6ed546566ae9f3db4e573dbe43e43968f5885c9602c5ca198ceb8a7801aca769e499ef4d10acaaf2be318f779f
7
+ data.tar.gz: 01b21d439cc5b7d1c8ff218620b7eec13a8496919c941863df25d8d01f4d2c6d11b727a6c4269015ef61d1d8063ebe1487909c3b238c84c06c5211eccc568423
@@ -3,6 +3,8 @@ module Startback
3
3
  class LogFormatter
4
4
 
5
5
  def call(severity, time, progname, msg)
6
+ msg = { message: msg } if msg.is_a?(String)
7
+ msg = { error: msg } if msg.is_a?(Exception)
6
8
  {
7
9
  severity: severity,
8
10
  time: time
@@ -67,6 +67,8 @@ module Startback
67
67
  log_msg.dup
68
68
  elsif log_msg.is_a?(String)
69
69
  log_msg = { op: "#{log_msg}#{method.nil? ? '' : '#'+method.to_s}" }
70
+ elsif log_msg.is_a?(Exception)
71
+ log_msg = { error: log_msg }
70
72
  else
71
73
  log_msg = log_msg.class unless log_msg.is_a?(Module)
72
74
  log_msg = { op: "#{log_msg.name}##{method}" }
@@ -2,7 +2,7 @@ module Startback
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 11
5
- TINY = 3
5
+ TINY = 4
6
6
  end
7
7
  VERSION = "#{Version::MAJOR}.#{Version::MINOR}.#{Version::TINY}"
8
8
  end
@@ -135,6 +135,16 @@ module Startback
135
135
  expect(logger).to be_a(::Logger)
136
136
  end
137
137
 
138
+ it 'works fine with a Exception only' do
139
+ exception = StandardError.new('hello')
140
+ expected = {
141
+ error: exception
142
+ }
143
+ log_msg, logger = parse_args(exception)
144
+ expect(log_msg).to eql(expected)
145
+ expect(logger).to be_a(::Logger)
146
+ end
147
+
138
148
  it 'works fine with a string and a context with logger' do
139
149
  expected = {
140
150
  op: "a message"
@@ -216,4 +226,4 @@ module Startback
216
226
 
217
227
  end
218
228
  end
219
- end
229
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: startback
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.3
4
+ version: 0.11.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bernard Lambeau
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-10 00:00:00.000000000 Z
11
+ date: 2022-05-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec