lorekeeper 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lorekeeper/fast_logger.rb +9 -4
- data/lib/lorekeeper/json_logger.rb +10 -6
- data/lib/lorekeeper/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aadbee0bac5c03a25508d71162e6fd6e1684f168
|
4
|
+
data.tar.gz: e11ee8efb4e4e0aff367e7d1a29ccb462b1ccd30
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf16fbacc7fae49dbcc81a2e61e0c1865276c62fd6a2345d06be0ba65b0083c0aca08282ac703405e71b26c78646f7db6dc549c2816ee3a20108205dcbb3dc21
|
7
|
+
data.tar.gz: e94fdc0f7149b0cd29c738bc2a3dc627fd414341992af5771689bd6bee11c29d354a3926dedd2cbe2aa601cfa01959c03c846825143faffd9d508020a09a6145
|
@@ -29,14 +29,19 @@ module Lorekeeper
|
|
29
29
|
# We support a string as a parameter and also a block
|
30
30
|
LOGGING_METHODS.each do |method_name|
|
31
31
|
define_method method_name.to_s, ->(message_param = nil, &block) do
|
32
|
-
|
33
|
-
message = message_param || (block && block.call)
|
34
|
-
log_data(method_name, message.freeze)
|
32
|
+
add(METHOD_SEVERITY_MAP[method_name], message_param, nil, &block)
|
35
33
|
end
|
36
34
|
end
|
37
35
|
|
36
|
+
# This is part of the standard Logger API, we need this to be compatible
|
37
|
+
def add(severity, message_param = nil, progname = nil, &block)
|
38
|
+
return true if severity < @level
|
39
|
+
message = message_param || (block && block.call)
|
40
|
+
log_data(severity, message.freeze)
|
41
|
+
end
|
42
|
+
|
38
43
|
# inherited classes probably want to reimplement this
|
39
|
-
def log_data(
|
44
|
+
def log_data(_severity, message)
|
40
45
|
@iodevice.write(message)
|
41
46
|
end
|
42
47
|
|
@@ -31,8 +31,9 @@ module Lorekeeper
|
|
31
31
|
define_method "#{method_name}_with_data", ->(message_param = nil, data = {}, &block) do
|
32
32
|
return true if METHOD_SEVERITY_MAP[method_name] < @level
|
33
33
|
extra_fields = {'data' => (data || {}) }
|
34
|
-
|
35
|
-
|
34
|
+
with_extra_fields(extra_fields) do
|
35
|
+
add(METHOD_SEVERITY_MAP[method_name], message_param, nil, &block)
|
36
|
+
end
|
36
37
|
end
|
37
38
|
end
|
38
39
|
|
@@ -99,7 +100,7 @@ module Lorekeeper
|
|
99
100
|
end
|
100
101
|
end
|
101
102
|
|
102
|
-
def log_data(
|
103
|
+
def log_data(_severity, message)
|
103
104
|
# merging is slow, we do not want to merge with empty hash if possible
|
104
105
|
fields_to_log = if state[:extra_fields].empty?
|
105
106
|
state[:base_fields]
|
@@ -116,10 +117,13 @@ module Lorekeeper
|
|
116
117
|
|
117
118
|
# Simple logger which tries to have an easy to see output.
|
118
119
|
class SimpleLogger < FastLogger
|
119
|
-
SEVERITY_TO_COLOR_MAP
|
120
|
+
SEVERITY_TO_COLOR_MAP = {
|
121
|
+
DEBUG => '0;37', INFO => '0;37', WARN => '33',
|
122
|
+
ERROR => '31', FATAL => '31', UNKNOWN => '37'
|
123
|
+
}
|
120
124
|
|
121
|
-
def log_data(
|
122
|
-
color = SEVERITY_TO_COLOR_MAP[
|
125
|
+
def log_data(severity, message)
|
126
|
+
color = SEVERITY_TO_COLOR_MAP[severity]
|
123
127
|
@iodevice.write("\033[#{color}m#{message}\033[0m\n")
|
124
128
|
end
|
125
129
|
end
|
data/lib/lorekeeper/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lorekeeper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jordi Polo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oj
|
@@ -169,3 +169,4 @@ signing_key:
|
|
169
169
|
specification_version: 4
|
170
170
|
summary: Very fast JSON logger
|
171
171
|
test_files: []
|
172
|
+
has_rdoc:
|