logger_ext 0.2.1 → 0.3.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 +31 -16
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef3ac737912e22bb15e2ca8656a8598b78d827b6
|
4
|
+
data.tar.gz: d98e438a94941ab35706ddb4c479bd32b7606d2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 717f95e125a5fa81376b68bc421a634da8ab299b92ec4d5fb6239114f7fab6e1ba4bd6485929beab2916d617e1b873683069b0d7b3a5baf3b0fd9dcf20a5eb31
|
7
|
+
data.tar.gz: 39d8866e704bde4381a0e5ec002ee04bf7d83571d8d80d94bba02e512cc5ff5f6743d2d221131e298c7f10c5d31393d77e1691b31f6943b318361ebf0d22b2e2
|
data/lib/logger_ext/version.rb
CHANGED
data/lib/logger_ext.rb
CHANGED
@@ -2,56 +2,71 @@ require "logger_ext/version"
|
|
2
2
|
require "logger"
|
3
3
|
|
4
4
|
class Logger
|
5
|
+
class ExtendedMessage
|
6
|
+
attr_reader :message
|
7
|
+
attr_reader :args
|
8
|
+
|
9
|
+
def initialize(message, *args)
|
10
|
+
@message = message
|
11
|
+
@args = args
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_s
|
15
|
+
if args.length == 0
|
16
|
+
message
|
17
|
+
else
|
18
|
+
s = "#{message}: #{args.shift.inspect}"
|
19
|
+
args.each_with_index do |arg, idx|
|
20
|
+
next if idx == 0
|
21
|
+
s += ", #{arg.inspect}"
|
22
|
+
end
|
23
|
+
s
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
5
28
|
private
|
6
29
|
|
7
|
-
def
|
30
|
+
def add_with_options(severity, *args, &block)
|
8
31
|
return unless level <= severity
|
9
32
|
|
10
33
|
if block
|
11
34
|
# Note: this will raise an error if args is not empty
|
12
35
|
add severity, nil, *args, &block
|
13
36
|
else
|
14
|
-
add severity,
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def format_message_with_options(message, *args)
|
19
|
-
message += ": #{args.shift.inspect}" unless args.empty?
|
20
|
-
args.each_with_index do |arg, idx|
|
21
|
-
message += ", #{arg.inspect}"
|
37
|
+
add severity, ExtendedMessage.new(*args), nil
|
22
38
|
end
|
23
|
-
message
|
24
39
|
end
|
25
40
|
|
26
41
|
public
|
27
42
|
|
28
43
|
# Log a +DEBUG+ message.
|
29
44
|
def debug(*args, &block)
|
30
|
-
|
45
|
+
add_with_options(DEBUG, *args, &block)
|
31
46
|
end
|
32
47
|
|
33
48
|
# Log an +INFO+ message.
|
34
49
|
def info(*args, &block)
|
35
|
-
|
50
|
+
add_with_options(INFO, *args, &block)
|
36
51
|
end
|
37
52
|
|
38
53
|
# Log a +WARN+ message.
|
39
54
|
def warn(*args, &block)
|
40
|
-
|
55
|
+
add_with_options(WARN, *args, &block)
|
41
56
|
end
|
42
57
|
|
43
58
|
# Log an +ERROR+ message.
|
44
59
|
def error(*args, &block)
|
45
|
-
|
60
|
+
add_with_options(ERROR, *args, &block)
|
46
61
|
end
|
47
62
|
|
48
63
|
# Log a +FATAL+ message.
|
49
64
|
def fatal(*args, &block)
|
50
|
-
|
65
|
+
add_with_options(FATAL, *args, &block)
|
51
66
|
end
|
52
67
|
|
53
68
|
# Log an +UNKNOWN+ message.
|
54
69
|
def unknown(*args, &block)
|
55
|
-
|
70
|
+
add_with_options(UNKNOWN, *args, &block)
|
56
71
|
end
|
57
72
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logger_ext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- radiospiel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|