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 +4 -4
- data/lib/logger_ext/version.rb +1 -1
- data/lib/logger_ext.rb +20 -12
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0390159cf17c35f3152011ab85bfe284a7c1add
|
4
|
+
data.tar.gz: 02a1fe3f3f37f51de9f530eed571c82f431e5553
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56d5a95c99ca53be7855a8b877207e9e89490def02dba596f5faa1eec92c8da011b83da813355f52d449b62ecf1cc1936f23a8e7cdf969b99bc945ad6f5af9b1
|
7
|
+
data.tar.gz: 8ebaac833865d8ff0c57bd3f47e6fe2de13dd1d986140ad86cd8e18d603d3db71f31eedaa7d6f0eb5d9fcfb283668ef024cf7455a16c7079375127b4d48ddfbd
|
data/lib/logger_ext/version.rb
CHANGED
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
55
|
+
add_structured_entry(UNKNOWN, message, *args, &block)
|
48
56
|
end
|
49
57
|
end
|