slog 1.1.2 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/slog/logger.rb +40 -30
- metadata +15 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28b7cbba69916bb491bcd136723d67836a96f3d1
|
4
|
+
data.tar.gz: 0e6c43f58208fc56a01870f1e0afc0cafe40967d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15d26360ccbb40a3c116a99138d43692708809cceb018397aa73b175d6ee719e8529d3094f8ba2911c1eecb8f5e8a2e12f467cfe51db1d84006f96a6dc954eee
|
7
|
+
data.tar.gz: 067230f49eba3e25075c1f9453f7fad893929bf140295468f2440105a01d0700ea8488ee07abaaa62d24df2d1abfb16f79248a84a871ffbefc443d05b5b80bdb
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.3
|
data/lib/slog/logger.rb
CHANGED
@@ -34,38 +34,48 @@ module Slog
|
|
34
34
|
# A little different than the canonical Logger. Add options to set the
|
35
35
|
# log level and to disable both colorization and pretty JSON output. In
|
36
36
|
# this form, it's perfect for use with either Logstash or Franz.
|
37
|
-
def initialize
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
37
|
+
def initialize conf={}
|
38
|
+
defaults = {
|
39
|
+
out: $stdout, # Output handle
|
40
|
+
shift_age: 7, # Max seven logs
|
41
|
+
shift_size: 1_048_576, # 1024 KiB
|
42
|
+
colorize: nil, # nil to guess
|
43
|
+
prettify: nil, # nil to guess
|
44
|
+
level: :info, # INFO
|
45
|
+
level_transform: 'downcase', # Any String method
|
46
|
+
level_field: 'level', # nil to disable
|
47
|
+
message_field: 'message', # nil to disable
|
48
|
+
timestamp_field: '@timestamp', # nil to disable
|
49
|
+
timestamp_format: '%FT%T.%3N%:z', # ISO-8601
|
50
|
+
color_map: {
|
51
|
+
'debug' => [ :blue, :default ],
|
52
|
+
'info' => [ :green, :default ],
|
53
|
+
'warn' => [ :yellow, :default ],
|
54
|
+
'error' => [ :red, :default ],
|
55
|
+
'fatal' => [ :red, :black ],
|
56
|
+
'trace' => [ :magenta, :default ]
|
57
|
+
}
|
56
58
|
}
|
57
59
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
60
|
+
conf = defaults.merge(conf)
|
61
|
+
|
62
|
+
begin
|
63
|
+
conf[:colorize] = true if conf[:out].tty? && conf[:colorize].nil?
|
64
|
+
conf[:prettify] = true if conf[:out].tty? && conf[:prettify].nil?
|
65
|
+
rescue NoMethodError
|
66
|
+
end
|
67
|
+
|
68
|
+
@prettify = conf[:prettify]
|
69
|
+
@colorize = conf[:colorize]
|
70
|
+
@color_map = conf[:color_map]
|
71
|
+
@level_field = conf[:level_field]
|
72
|
+
@level_transform = conf[:level_transform]
|
73
|
+
@message_field = conf[:message_field]
|
74
|
+
@timestamp_field = conf[:timestamp_field]
|
75
|
+
@timestamp_format = conf[:timestamp_format]
|
76
|
+
|
77
|
+
super conf[:out], conf[:shift_age], conf[:shift_size]
|
78
|
+
self.level = conf[:level]
|
69
79
|
|
70
80
|
set_formatter
|
71
81
|
end
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Clemmer
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name: colorize
|
15
14
|
requirement: !ruby/object:Gem::Requirement
|
16
15
|
requirements:
|
17
|
-
- -
|
16
|
+
- - ~>
|
18
17
|
- !ruby/object:Gem::Version
|
19
18
|
version: '0'
|
20
|
-
|
19
|
+
name: colorize
|
21
20
|
prerelease: false
|
21
|
+
type: :runtime
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
description: Easy structured logging.
|
@@ -30,8 +30,8 @@ executables: []
|
|
30
30
|
extensions: []
|
31
31
|
extra_rdoc_files: []
|
32
32
|
files:
|
33
|
-
-
|
34
|
-
-
|
33
|
+
- .gitignore
|
34
|
+
- .rubocop.yml
|
35
35
|
- Gemfile
|
36
36
|
- LICENSE
|
37
37
|
- README.md
|
@@ -47,24 +47,24 @@ homepage: https://github.com/sczizzo/slog
|
|
47
47
|
licenses:
|
48
48
|
- ISC
|
49
49
|
metadata: {}
|
50
|
-
post_install_message:
|
50
|
+
post_install_message:
|
51
51
|
rdoc_options: []
|
52
52
|
require_paths:
|
53
53
|
- lib
|
54
54
|
required_ruby_version: !ruby/object:Gem::Requirement
|
55
55
|
requirements:
|
56
|
-
- -
|
56
|
+
- - '>='
|
57
57
|
- !ruby/object:Gem::Version
|
58
58
|
version: '0'
|
59
59
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
60
|
requirements:
|
61
|
-
- -
|
61
|
+
- - '>='
|
62
62
|
- !ruby/object:Gem::Version
|
63
63
|
version: '0'
|
64
64
|
requirements: []
|
65
|
-
rubyforge_project:
|
66
|
-
rubygems_version: 2.
|
67
|
-
signing_key:
|
65
|
+
rubyforge_project:
|
66
|
+
rubygems_version: 2.4.6
|
67
|
+
signing_key:
|
68
68
|
specification_version: 4
|
69
69
|
summary: Easy structured logging
|
70
70
|
test_files:
|