ougai 1.5.3 → 1.5.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
  SHA1:
3
- metadata.gz: 9c54bd7fa12af6d228cace05fc29a5b7d3505e29
4
- data.tar.gz: ed95bd29269e64789b7d32d23cc28dea027ef8cf
3
+ metadata.gz: 97be7511c1c17536603cf512a2f8c107e40ff021
4
+ data.tar.gz: e2c08a3c8e6833e0ef2622d0fb264b75dba77e94
5
5
  SHA512:
6
- metadata.gz: 23bc030f29a729ee496228a21c9f42962b057801a9f7bc4cb857e73818a55eac9365ef326f40edb8c70b9907d44dc5570bd8e660e88f6df45414fe57bc22263c
7
- data.tar.gz: a9ec8277f83d6c02ffcced038af1ceeaadd1564a6982bbf23bb6b37c0471a739e3b463c691a45c0fc07ce379062c7ebdc654621a29d6a37955b2721efb7562a6
6
+ metadata.gz: d457ca8fbff8a3a22003eb9c4878b7b0af931a04d58d89f950733ab80a22de0095f5ee5a16d4c6f8b7695d327434ea12c9629710656df3a32c9543bf1de5c39b
7
+ data.tar.gz: '0974027ba5cd59d0e8418abb5a2e5b89ee0145cd7cf002d9ea497c871b4c2305952ac3bf56bb06ac5298eb5d8b74f20e2d674aacd8d62e5081861aa4fc853dc8'
@@ -14,20 +14,26 @@ module Ougai
14
14
  @trace_indent = opts[:trace_indent] || 4
15
15
  @plain = opts[:plain] || false
16
16
  @excluded_fields = opts[:excluded_fields] || []
17
- load_awesome_print
17
+ load_dependent
18
18
  end
19
19
 
20
20
  def call(severity, time, progname, data)
21
21
  msg = data.delete(:msg)
22
22
  level = @plain ? severity : colored_level(severity)
23
- strs = ["[#{format_datetime(time)}] #{level}: #{msg}"]
24
- if err_str = create_err_str(data)
25
- strs.push(err_str)
26
- end
23
+ dt = format_datetime(time)
24
+ err_str = create_err_str(data)
25
+
27
26
  @excluded_fields.each { |f| data.delete(f) }
28
- unless data.empty?
29
- strs.push(data.ai({ plain: @plain }))
30
- end
27
+ data_str = create_data_str(data)
28
+ format_log_parts(dt, level, msg, err_str, data_str)
29
+ end
30
+
31
+ protected
32
+
33
+ def format_log_parts(datetime, level, msg, err, data)
34
+ strs = ["[#{datetime}] #{level}: #{msg}"]
35
+ strs.push(err) if err
36
+ strs.push(data) if data
31
37
  strs.join("\n") + "\n"
32
38
  end
33
39
 
@@ -59,9 +65,12 @@ module Ougai
59
65
  err_str
60
66
  end
61
67
 
62
- private
68
+ def create_data_str(data)
69
+ return nil if data.empty?
70
+ data.ai({ plain: @plain })
71
+ end
63
72
 
64
- def load_awesome_print
73
+ def load_dependent
65
74
  require 'awesome_print'
66
75
  rescue LoadError
67
76
  puts 'You must install the awesome_print gem to use this output.'
@@ -1,3 +1,3 @@
1
1
  module Ougai
2
- VERSION = "1.5.3"
2
+ VERSION = "1.5.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ougai
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.3
4
+ version: 1.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toshimitsu Takahashi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-17 00:00:00.000000000 Z
11
+ date: 2017-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler