lorekeeper 1.5.1 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/lorekeeper.rb +1 -0
- data/lib/lorekeeper/json_logger.rb +0 -36
- data/lib/lorekeeper/simple_logger.rb +52 -0
- 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: b7f9cc1ad4f01d7ba6b9301762f3c2be2a9b865f
|
4
|
+
data.tar.gz: df9ed29c2ff9294cbc0dc8aa6bd7e01373527a6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1010ae953b8a32ae377dbe4f6e011f5399a50a4e8a3f5988a889892c3ddde6cc16f395673889520016d4c725a6a2f99910e4e4ebf8ab3c58037e36156e893639
|
7
|
+
data.tar.gz: 2532bbf0078364bc8cb14652086f0492e8aaf1c3a2f805c625cb395cab851ec36ce8223d566551c6729b09338e262118d5a32c8eb5a774b2eb579a4a5552c4bf
|
data/CHANGELOG.md
CHANGED
data/lib/lorekeeper.rb
CHANGED
@@ -119,40 +119,4 @@ module Lorekeeper
|
|
119
119
|
end
|
120
120
|
end
|
121
121
|
|
122
|
-
# Simple logger which tries to have an easy to see output.
|
123
|
-
class SimpleLogger < FastLogger
|
124
|
-
# From http://misc.flogisoft.com/bash/tip_colors_and_formatting
|
125
|
-
# 39: default for the theme
|
126
|
-
# 33: yellow
|
127
|
-
# 31: red
|
128
|
-
# 37: light gray
|
129
|
-
SEVERITY_TO_COLOR_MAP = {
|
130
|
-
DEBUG => '39'.freeze,
|
131
|
-
INFO => DEBUG,
|
132
|
-
WARN => '33'.freeze,
|
133
|
-
ERROR => '31'.freeze,
|
134
|
-
FATAL => ERROR,
|
135
|
-
UNKNOWN => '37'.freeze
|
136
|
-
}.freeze
|
137
|
-
|
138
|
-
# \e[colorm sets a color \e[0m resets all properties
|
139
|
-
def log_data(severity, message)
|
140
|
-
color = SEVERITY_TO_COLOR_MAP[severity]
|
141
|
-
@iodevice.write("\e[#{color}m#{message}\e[0m\n")
|
142
|
-
end
|
143
|
-
|
144
|
-
def inspect
|
145
|
-
"Lorekeeper Simple logger. IO: #{@file.inspect}"
|
146
|
-
end
|
147
|
-
|
148
|
-
# Extending the logger API with methods error_with_data, etc
|
149
|
-
LOGGING_METHODS.each do |method_name|
|
150
|
-
define_method "#{method_name}_with_data", ->(message_param = nil, data = {}, &block) do
|
151
|
-
return true if METHOD_SEVERITY_MAP[method_name] < @level
|
152
|
-
log_data(METHOD_SEVERITY_MAP[method_name], "#{message_param}, data: #{data}")
|
153
|
-
end
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
|
158
122
|
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# The comment above will make all strings in a current file frozen
|
3
|
+
require 'lorekeeper/fast_logger'
|
4
|
+
|
5
|
+
module Lorekeeper
|
6
|
+
# Simple logger provides a logger which outputs messages in a colorized simple text format.
|
7
|
+
class SimpleLogger < FastLogger
|
8
|
+
# From http://misc.flogisoft.com/bash/tip_colors_and_formatting
|
9
|
+
# 39: default for the theme
|
10
|
+
# 33: yellow
|
11
|
+
# 31: red
|
12
|
+
# 37: light gray
|
13
|
+
SEVERITY_TO_COLOR_MAP = {
|
14
|
+
DEBUG => '39'.freeze,
|
15
|
+
INFO => DEBUG,
|
16
|
+
WARN => '33'.freeze,
|
17
|
+
ERROR => '31'.freeze,
|
18
|
+
FATAL => ERROR,
|
19
|
+
UNKNOWN => '37'.freeze
|
20
|
+
}.freeze
|
21
|
+
|
22
|
+
# \e[colorm sets a color \e[0m resets all properties
|
23
|
+
def log_data(severity, message)
|
24
|
+
color = SEVERITY_TO_COLOR_MAP[severity]
|
25
|
+
@iodevice.write("\e[#{color}m#{message}\e[0m\n")
|
26
|
+
end
|
27
|
+
|
28
|
+
def inspect
|
29
|
+
"Lorekeeper Simple logger. IO: #{@file.inspect}"
|
30
|
+
end
|
31
|
+
|
32
|
+
# Extending the logger API with methods error_with_data, etc
|
33
|
+
LOGGING_METHODS.each do |method_name|
|
34
|
+
define_method "#{method_name}_with_data", ->(message_param = nil, data = {}, &block) do
|
35
|
+
return true if METHOD_SEVERITY_MAP[method_name] < @level
|
36
|
+
log_data(METHOD_SEVERITY_MAP[method_name], "#{message_param}, data: #{data}")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def exception(exception, custom_message = nil, custom_data = nil)
|
41
|
+
if exception.is_a?(Exception)
|
42
|
+
backtrace = exception.backtrace || []
|
43
|
+
message = custom_message || exception.message
|
44
|
+
error_with_data("#{exception.class}: #{message}", backtrace.join("\n"))
|
45
|
+
else
|
46
|
+
log_data(:warning, 'Logger exception called without exception class.')
|
47
|
+
error_with_data("#{exception.class}: #{exception.inspect} #{custom_message}", custom_data)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
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.6.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-09-
|
11
|
+
date: 2016-09-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oj
|
@@ -144,6 +144,7 @@ files:
|
|
144
144
|
- lib/lorekeeper/fast_logger.rb
|
145
145
|
- lib/lorekeeper/json_logger.rb
|
146
146
|
- lib/lorekeeper/multi_logger.rb
|
147
|
+
- lib/lorekeeper/simple_logger.rb
|
147
148
|
- lib/lorekeeper/version.rb
|
148
149
|
- lorekeeper.gemspec
|
149
150
|
homepage: http://www.github.com/jordipolo/lorekeeper
|