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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ea967448298e4caf36e0036c83a2d606a35757c
|
4
|
+
data.tar.gz: 1caa3d85c6624837c7c49cd105e41047b61dce9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 519954f3a6dbce08346df7935a3eb73e3d0fe3e79391c1592a146f488997596b9f88cfa8337a8cbf8f668fc2469b4825f71735b66ad3ea8b40e12cb00ab0af38
|
7
|
+
data.tar.gz: f27967c4fcbeb77342a9c7eb06918d2b541f357df6d3554bc925f83ca6414ee0b6481b22c69ab32e390b771a61b21e2d06d0989d36423bdf8f298b1e48d97c69
|
@@ -1,12 +1,31 @@
|
|
1
1
|
class ExtendedLogger
|
2
|
-
class 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
|
-
|
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
|
-
|
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 =
|
39
|
+
formatted_line = formatter.(*arguments, line)
|
21
40
|
output << formatted_line
|
22
41
|
output
|
23
42
|
end
|
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.
|
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-
|
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,
|