logger_ext 0.1.4 → 0.2.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
  SHA1:
3
- metadata.gz: b9fdadfae22e13d3fa0406fc25cad5554c3e8416
4
- data.tar.gz: 3455b8b78426133eb3c148ab9acd8bc2df6fd54f
3
+ metadata.gz: c0390159cf17c35f3152011ab85bfe284a7c1add
4
+ data.tar.gz: 02a1fe3f3f37f51de9f530eed571c82f431e5553
5
5
  SHA512:
6
- metadata.gz: cec99f31d54d4598b82225ad1b1ced61cb077323a09243aa7e37e27e05cadfd8c26fc21fb70e7a97fb343830ac0a7531f50c64a551bd0a92426943410fdf3038
7
- data.tar.gz: 3c5af72311a22dcd0632fbbe5eff0aa765211140c5d7426617419b742421568e6f61220d3bba3baa6d12f330d3909888dc798bba295d0a371fd64573188fa63c
6
+ metadata.gz: 56d5a95c99ca53be7855a8b877207e9e89490def02dba596f5faa1eec92c8da011b83da813355f52d449b62ecf1cc1936f23a8e7cdf969b99bc945ad6f5af9b1
7
+ data.tar.gz: 8ebaac833865d8ff0c57bd3f47e6fe2de13dd1d986140ad86cd8e18d603d3db71f31eedaa7d6f0eb5d9fcfb283668ef024cf7455a16c7079375127b4d48ddfbd
@@ -1,3 +1,3 @@
1
1
  module LoggerExt
2
- VERSION = "0.1.4"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/logger_ext.rb CHANGED
@@ -2,48 +2,56 @@ require "logger_ext/version"
2
2
  require "logger"
3
3
 
4
4
  class Logger
5
- def add_structured(severity, message, *args, &block)
5
+ private
6
+
7
+ def add_structured_entry(severity, message, *args, &block)
6
8
  return unless level <= severity
7
9
 
8
10
  if block
9
11
  # Note: this will raise an error if args is not empty
10
12
  add severity, nil, message, *args, &block
11
13
  else
12
- message += ": #{args.shift.inspect}" unless args.empty?
13
- args.each_with_index do |arg, idx|
14
- message += ", #{arg.inspect}"
15
- end
16
- add severity, message, nil
14
+ add severity, format_structured_entry(message, *args), nil
17
15
  end
18
16
  end
19
17
 
18
+ def format_structured_entry(message, *args)
19
+ message += ": #{args.shift.inspect}" unless args.empty?
20
+ args.each_with_index do |arg, idx|
21
+ message += ", #{arg.inspect}"
22
+ end
23
+ message
24
+ end
25
+
26
+ public
27
+
20
28
  # Log a +DEBUG+ message.
21
29
  def debug(message, *args, &block)
22
- add_structured(DEBUG, message, *args, &block)
30
+ add_structured_entry(DEBUG, message, *args, &block)
23
31
  end
24
32
 
25
33
  # Log an +INFO+ message.
26
34
  def info(message, *args, &block)
27
- add_structured(INFO, message, *args, &block)
35
+ add_structured_entry(INFO, message, *args, &block)
28
36
  end
29
37
 
30
38
  # Log a +WARN+ message.
31
39
  def warn(message, *args, &block)
32
- add_structured(WARN, message, *args, &block)
40
+ add_structured_entry(WARN, message, *args, &block)
33
41
  end
34
42
 
35
43
  # Log an +ERROR+ message.
36
44
  def error(message, *args, &block)
37
- add_structured(ERROR, message, *args, &block)
45
+ add_structured_entry(ERROR, message, *args, &block)
38
46
  end
39
47
 
40
48
  # Log a +FATAL+ message.
41
49
  def fatal(message, *args, &block)
42
- add_structured(FATAL, message, *args, &block)
50
+ add_structured_entry(FATAL, message, *args, &block)
43
51
  end
44
52
 
45
53
  # Log an +UNKNOWN+ message.
46
54
  def unknown(message, *args, &block)
47
- add_structured(UNKNOWN, message, *args, &block)
55
+ add_structured_entry(UNKNOWN, message, *args, &block)
48
56
  end
49
57
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logger_ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - radiospiel