slog 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/lib/slog/logger.rb +40 -30
  4. metadata +15 -15
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 807f84e2e864292179810e7450ac37696a2f5f16
4
- data.tar.gz: a788a44e6f8d9bff31b07c8d99524345662cb795
3
+ metadata.gz: 28b7cbba69916bb491bcd136723d67836a96f3d1
4
+ data.tar.gz: 0e6c43f58208fc56a01870f1e0afc0cafe40967d
5
5
  SHA512:
6
- metadata.gz: 8403f63e3dcfd2ffdc5837933884ae6bc85ab22853e7ae1e5ff731c7548dfd901ff90a684f3e2e18e370d9937bc7bd4edd4d6dd8c950ca709795d2d7824328fb
7
- data.tar.gz: acaf99f7d3cc3732b0b9a276f91e6c4279dcc4bf2ac5952592abdfe301ac2e884bf9e059c5430f7b5c2cb5eb76b6cce11202fef3ae28cb656c1af69443d71af2
6
+ metadata.gz: 15d26360ccbb40a3c116a99138d43692708809cceb018397aa73b175d6ee719e8529d3094f8ba2911c1eecb8f5e8a2e12f467cfe51db1d84006f96a6dc954eee
7
+ data.tar.gz: 067230f49eba3e25075c1f9453f7fad893929bf140295468f2440105a01d0700ea8488ee07abaaa62d24df2d1abfb16f79248a84a871ffbefc443d05b5b80bdb
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.2
1
+ 1.1.3
@@ -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
- out: $stdout, # Output handle
39
- shift_age: 7, # Max seven logs
40
- shift_size: 1_048_576, # 1024 KiB
41
- colorize: true, # Disable for files
42
- prettify: true, # Disable for files
43
- level: :info, # INFO
44
- level_transform: 'downcase', # Any String method
45
- level_field: 'level', # nil to disable
46
- message_field: 'message', # nil to disable
47
- timestamp_field: '@timestamp', # nil to disable
48
- timestamp_format: '%FT%T.%3N%:z', # ISO-8601
49
- color_map: {
50
- 'debug' => [ :blue, :default ],
51
- 'info' => [ :green, :default ],
52
- 'warn' => [ :yellow, :default ],
53
- 'error' => [ :red, :default ],
54
- 'fatal' => [ :red, :black ],
55
- 'trace' => [ :magenta, :default ]
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
- @prettify = prettify
59
- @colorize = colorize
60
- @color_map = color_map
61
- @level_field = level_field
62
- @level_transform = level_transform
63
- @message_field = message_field
64
- @timestamp_field = timestamp_field
65
- @timestamp_format = timestamp_format
66
-
67
- super out, shift_age, shift_size
68
- self.level = level
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.2
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-01-01 00:00:00.000000000 Z
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
- type: :runtime
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
- - ".gitignore"
34
- - ".rubocop.yml"
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.2.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: