extended_logger 0.5.2 → 0.5.3

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: 375150a4e2c1c8d8e3b23f85ba5d85d7e9380c7a
4
- data.tar.gz: 2595ad3267a0c4eb828bf89e040a64a476ab402a
3
+ metadata.gz: 4f455250170001f45e0124012bea062f08d8d072
4
+ data.tar.gz: 783a45d09ed579227e8b343e3cd3732fae593fab
5
5
  SHA512:
6
- metadata.gz: 7b685fcf5454fce6d6bc1f3fb0967ca27f122fabcca2f1f7d31da421401e32d48d77c1140141d6584bbbb7fe27a2bc6595397d2cfbb4ab6a79f633eebb6fc8bc
7
- data.tar.gz: 3c04f2cfd6fca9e335b3ef50de482c125e41e32cfbdb86513367d05e7af4012fb66daf4658ff20ddd52370cb57e0d3fbf4db372214a4d35072712d50be0e8030
6
+ metadata.gz: b5e3b1f15f2f8d7caa9416cc4c58e76296278daec801a54444203ac47b6685ec54961e7cfa1752f1b5fd6ee322d3a709701dfe892172ef41e5c64a4be8a1bc89
7
+ data.tar.gz: 3df9a339830cf81d580f610da7fa88053c7b30cb559d960759ed709b56c28d25e7abc3482d3bed3ddacf0794091a6a320501b6bb7c19e4e75093bdfa982d3411
@@ -96,6 +96,22 @@ class ExtendedLogger
96
96
  new map
97
97
  end
98
98
 
99
+ def self.resolve input
100
+ case input
101
+ when String then self.load input
102
+ when true then Default
103
+ else raise ArgumentError, "Cannot resolve color scheme for #{input.inspect}"
104
+ end
105
+ end
106
+
107
+ AssignmentPattern = %r{\A
108
+ (?<label>[_A-Z]+)
109
+ =
110
+ (?<fg_code>[?[:xdigit:]])+
111
+ ;
112
+ (?<bg_code>[?[:xdigit:]]+)\z
113
+ }nx
114
+
99
115
  Colors = %i(
100
116
  black
101
117
  red
@@ -116,13 +132,14 @@ class ExtendedLogger
116
132
  white
117
133
  )
118
134
 
119
- AssignmentPattern = %r{\A
120
- (?<label>[_A-Z]+)
121
- =
122
- (?<fg_code>[?[:xdigit:]])+
123
- ;
124
- (?<bg_code>[?[:xdigit:]]+)\z
125
- }nx
135
+ Default = self.build(
136
+ 'DEBUG' => [:cyan, nil],
137
+ 'INFO' => [nil, nil],
138
+ 'WARN' => [:brown, nil],
139
+ 'ERROR' => [:red, nil],
140
+ 'FATAL' => [:white, :red],
141
+ 'ANY' => [:white, :blue],
142
+ )
126
143
 
127
144
  Null = self.new Hash.new
128
145
  end
@@ -10,8 +10,8 @@ class ExtendedLogger
10
10
 
11
11
  instance.always_interpolate = true if always_interpolate
12
12
 
13
- if color_scheme
14
- color_scheme = ColorScheme.load color_scheme if color_scheme.is_a? String
13
+ if color_scheme and io.tty?
14
+ color_scheme = ColorScheme.resolve color_scheme
15
15
  instance.color_scheme = color_scheme
16
16
  end
17
17
 
@@ -25,7 +25,7 @@ class ExtendedLogger
25
25
 
26
26
  def format formatter, *arguments, message
27
27
  message = message.to_s
28
- message = message.dup if message.frozen?
28
+ message = message.dup
29
29
 
30
30
  if BlankLine.match message.to_s
31
31
  formatter.(*arguments, '(empty log message)'.freeze)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: extended_logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Ladd
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-15 00:00:00.000000000 Z
11
+ date: 2016-01-16 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: 'An extended logger that provides a (mostly) substitutable alternative
14
14
  to ruby''s built in +Logger+ class. A number of useful extensions are provided,