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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 71ffd469643f224ae00f00a43a2d1b3722c1bf6b
4
- data.tar.gz: 77ed9aee28a33c8066fb3a2a9c73f07ad71ecbf3
3
+ metadata.gz: aadbee0bac5c03a25508d71162e6fd6e1684f168
4
+ data.tar.gz: e11ee8efb4e4e0aff367e7d1a29ccb462b1ccd30
5
5
  SHA512:
6
- metadata.gz: 84a7111da82f6cb7d23ae21c27bdf72c6af712a270f98dda7f771d3ba3934c15d9df47f1cbdbfe40655ec48c149c52f4a10c76e8ade212a8eaf21ee8fd40b323
7
- data.tar.gz: 7de9032c4d6aba109fa72dc9f50b73e40256ff668cc6cd79b5a1120c4826bd1abffd2f155060361cdeabbb43ab09aace4b39a123d1a74fa01c7a36f98ed6fbd3
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
- return true if METHOD_SEVERITY_MAP[method_name] < @level
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(_method_sym, message)
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
- message = message_param || (block && block.call)
35
- with_extra_fields(extra_fields) { log_data(method_name, message.freeze) }
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(_method_sym, message)
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 = {debug: '0;37', info: '0;37', warn: '33', error: '31', fatal: '31', unknown: '37'}
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(method_sym, message)
122
- color = SEVERITY_TO_COLOR_MAP[method_sym]
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  # The comment above will make all strings in a current file frozen
3
3
  module Lorekeeper
4
- VERSION = '1.0.0'
4
+ VERSION = '1.1.0'
5
5
  end
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.0.0
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-13 00:00:00.000000000 Z
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: