extended_logger 0.5.0 → 0.5.1

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: 47bdad0e0a33ecdf506b71aa4bb4784085583b19
4
- data.tar.gz: 7e3ae841f32d58d983af5d7062e4e18145ddba1a
3
+ metadata.gz: 4ea967448298e4caf36e0036c83a2d606a35757c
4
+ data.tar.gz: 1caa3d85c6624837c7c49cd105e41047b61dce9d
5
5
  SHA512:
6
- metadata.gz: 7f993016f5115afb6b3cf8a63a37dfc09209bdca075a1eff70666b0de2704502569325f811d1e7a61e9991091768615b11cc10b8c82ca81ff75e549ba21b3226
7
- data.tar.gz: 998ee7a2958d74795175ff3e69e138651b6eeeb40df13d506f81b28e6c53f367e611c36f4737deba6d3918ea65ef78fe29809770d46460d7f5d45cbd6b312cb4
6
+ metadata.gz: 519954f3a6dbce08346df7935a3eb73e3d0fe3e79391c1592a146f488997596b9f88cfa8337a8cbf8f668fc2469b4825f71735b66ad3ea8b40e12cb00ab0af38
7
+ data.tar.gz: f27967c4fcbeb77342a9c7eb06918d2b541f357df6d3554bc925f83ca6414ee0b6481b22c69ab32e390b771a61b21e2d06d0989d36423bdf8f298b1e48d97c69
@@ -68,6 +68,10 @@ class ExtendedLogger
68
68
  output
69
69
  end
70
70
 
71
+ def levels
72
+ map.keys
73
+ end
74
+
71
75
  def self.decode code
72
76
  return if code == '?'.freeze
73
77
  code.to_i 16
@@ -1,12 +1,31 @@
1
1
  class ExtendedLogger
2
- class Formatter < ::Logger::Formatter
2
+ class Formatter
3
3
  BlankLine = /\A[[:blank:]]*\z/n
4
4
  LineEnding = /[[:blank:]]*\r*[\r\n]/n
5
5
  Separator = "\n".freeze
6
6
 
7
- def call *arguments, message
7
+ attr_accessor :internal_formatter
8
+
9
+ def initialize internal_formatter
10
+ @internal_formatter = internal_formatter
11
+ end
12
+
13
+ def self.build
14
+ internal_formatter = ::Logger::Formatter.new
15
+ new internal_formatter
16
+ end
17
+
18
+ def call *arguments
19
+ format internal_formatter, *arguments
20
+ end
21
+
22
+ def datetime_format= format
23
+ internal_formatter.datetime_format = format
24
+ end
25
+
26
+ def format formatter, *arguments, message
8
27
  if BlankLine.match message.to_s
9
- super *arguments, '(empty log message)'.freeze
28
+ formatter.(*arguments, '(empty log message)'.freeze)
10
29
  else
11
30
  message.gsub! LineEnding do |line_ending|
12
31
  quoted = line_ending.inspect[1...-1]
@@ -17,7 +36,7 @@ class ExtendedLogger
17
36
  lines = message.split Separator
18
37
 
19
38
  lines.reduce String.new do |output, line|
20
- formatted_line = super *arguments, line
39
+ formatted_line = formatter.(*arguments, line)
21
40
  output << formatted_line
22
41
  output
23
42
  end
@@ -49,7 +49,7 @@ class ExtendedLogger
49
49
  end
50
50
 
51
51
  def default_formatter
52
- @default_formatter ||= Formatter.new
52
+ @default_formatter ||= Formatter.build
53
53
  end
54
54
 
55
55
  def format *arguments
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.0
4
+ version: 0.5.1
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-10 00:00:00.000000000 Z
11
+ date: 2016-01-13 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,