extended_logger 0.2.5 → 0.2.6

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: 432fe1b8c7b90b306ac342080870625f6ea874b0
4
- data.tar.gz: 74fad3a8306c04c1ab83af487fc3d9c92e435bc9
3
+ metadata.gz: 49556d004b36ef29b6255c074ec501261fc36b51
4
+ data.tar.gz: f07f8bf086584eacc2e4294def7cd9bc3d0521a8
5
5
  SHA512:
6
- metadata.gz: 02a3b0977675d38ebf7368db6f668e54a84bafec818fea7e966bf91ed8ade93827899b9c6657b112faa1853f261bfd8fc92705148c9ce1d6222cb2d023f3003d
7
- data.tar.gz: 3e2f94a828353d47bd656c3005af69c49c6a0a43bdfd57be1245508255329b1005a5bedbc873ee74890a72f403739fe97ef7b4c1882d0a4c834754460c15027c
6
+ metadata.gz: dee76927f44546a57acc7d6549cf1881d3e3e475a36b24c9f1785de66a42eb78e3ea49b843f67e5e214baa42b64932467d54996fd14668da3b0fad279165edc2
7
+ data.tar.gz: 5dfad9653cbd53610122e28a4b4be44f9bfbb39d947fb130274971be5218730dd87c257e78043a9539e55bbbef004787903b96a97dad4c42ace1e317a4310e4e
@@ -1,51 +1,55 @@
1
1
  class ExtendedLogger < Logger
2
- def self.configure receiver, attribute_name=nil, **overrides
3
- attribute_name ||= 'logger'.freeze
4
- setter = "#{attribute_name}=".freeze
2
+ class << self
3
+ attr_accessor :default_log_level
5
4
 
6
- logger = get receiver, **overrides
5
+ def configure receiver, attribute_name=nil, **overrides
6
+ attribute_name ||= 'logger'.freeze
7
+ setter = "#{attribute_name}=".freeze
7
8
 
8
- receiver.public_send setter, logger
9
- end
9
+ logger = get receiver, **overrides
10
10
 
11
- def self.get receiver, **overrides
12
- receiver_name =
13
- if receiver.is_a? Module
14
- receiver.name
15
- else
16
- receiver.class.name
17
- end
18
-
19
- logger = Factory.(**overrides)
20
- logger.progname = "(#{receiver_name})"
21
- logger
22
- end
11
+ receiver.public_send setter, logger
12
+ end
23
13
 
24
- def self.instance
25
- @instance ||= Factory.()
26
- end
14
+ def get receiver, **overrides
15
+ receiver_name =
16
+ if receiver.is_a? Module
17
+ receiver.name
18
+ else
19
+ receiver.class.name
20
+ end
27
21
 
28
- def self.levels
29
- @levels ||= {
30
- -7 => 'OBSOLETE'.freeze,
31
- -6 => 'OPT_DATA'.freeze,
32
- -5 => 'OPT_TRACE'.freeze,
33
- -4 => 'OPT_DEBUG'.freeze,
34
- -3 => 'DATA'.freeze,
35
- -2 => 'TRACE'.freeze,
36
- -1 => 'DEBUG'.freeze,
37
- 0 => 'INFO'.freeze,
38
- 1 => 'PASS'.freeze,
39
- 2 => 'FAIL'.freeze,
40
- 3 => 'FOCUS'.freeze,
41
- 4 => 'WARN'.freeze,
42
- 5 => 'ERROR'.freeze,
43
- 6 => 'FATAL'.freeze,
44
- }
45
- end
22
+ logger = Factory.(**overrides)
23
+ logger.progname = "(#{receiver_name})"
24
+ logger
25
+ end
46
26
 
47
- def self.level? level
48
- levels.key? level
27
+ def instance
28
+ @instance ||= Factory.()
29
+ end
30
+
31
+ def levels
32
+ @levels ||= {
33
+ -7 => 'OBSOLETE'.freeze,
34
+ -6 => 'OPT_DATA'.freeze,
35
+ -5 => 'OPT_TRACE'.freeze,
36
+ -4 => 'OPT_DEBUG'.freeze,
37
+ -3 => 'DATA'.freeze,
38
+ -2 => 'TRACE'.freeze,
39
+ -1 => 'DEBUG'.freeze,
40
+ 0 => 'INFO'.freeze,
41
+ 1 => 'PASS'.freeze,
42
+ 2 => 'FAIL'.freeze,
43
+ 3 => 'FOCUS'.freeze,
44
+ 4 => 'WARN'.freeze,
45
+ 5 => 'ERROR'.freeze,
46
+ 6 => 'FATAL'.freeze,
47
+ }
48
+ end
49
+
50
+ def level? level
51
+ levels.key? level
52
+ end
49
53
  end
50
54
 
51
55
  def datetime_format
@@ -10,6 +10,7 @@ class ExtendedLogger
10
10
 
11
11
  def self.build env=nil, device: nil, level: nil
12
12
  env ||= ENV
13
+ level ||= ExtendedLogger.default_log_level
13
14
 
14
15
  instance = new env
15
16
  instance.device = device if device
@@ -51,6 +52,7 @@ class ExtendedLogger
51
52
  level = ENV['LOG_LEVEL'] || @level
52
53
 
53
54
  return unless level
55
+ return level if level.is_a? Integer
54
56
 
55
57
  level , _ = ExtendedLogger.levels.rassoc level.upcase
56
58
  level
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: extended_logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Ladd