logbert 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/logbert/formatters.rb +10 -10
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YWFkNDk4ZjEyM2IxNTZjOGNiOTM0NzAxMmVmMjY5ZjZiMzU5M2JlZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NWU4MmNmY2IxMjdlMjI1ZTkyNDNiYzkxNTE3NmM5N2Y3Y2EzZmJjYg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZjFlMTk3NWE2YWMwZjBlZjk2NzMzZjJjM2FmMzYxYTZjYzI3NDhhNTNjZjVi
|
10
|
+
Mzk4MzNhNjc2N2U2YTFiMWE2MzRiMjMwOGE3OTgwMmNmNmY4ZDNjMWRkN2Vm
|
11
|
+
OTAwZjQ1NzMxNjkxNGYwNzgwNDg3OTVhYWI4Y2M3ZDAyOTFkZTU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZTc4ZmQzZDk3ZTVjNzQ4MTk4YTk0Yjc1NzU0MzVkOTE2MmJiZWQwNDQ2ZGRm
|
14
|
+
MjYxZmE2M2Y1MmQ2MDA5N2VjOGMzMjY5Mzk5ODc3NGRhNDhlNGIxMzdjM2M5
|
15
|
+
ZDJiNmU1OGY3ZDBmNzc3M2MzYmQ3ODlhYTZhNDY2MDg1NmE4ZDg=
|
data/lib/logbert/formatters.rb
CHANGED
@@ -2,36 +2,36 @@
|
|
2
2
|
require 'logbert/message'
|
3
3
|
|
4
4
|
module Logbert
|
5
|
-
|
5
|
+
|
6
6
|
module Formatters
|
7
|
-
|
7
|
+
|
8
8
|
class Formatter
|
9
9
|
def format(msg)
|
10
10
|
raise NotImplementedError
|
11
11
|
end
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
class SimpleFormatter < Formatter
|
15
15
|
def format(msg)
|
16
16
|
level = msg.level.to_s.upcase.ljust(8)
|
17
17
|
output = "#{level} [time='#{msg.time}' pid='#{msg.pid}' logger='#{msg.logger}'] : #{msg.content}"
|
18
18
|
if msg.exception
|
19
|
-
output = [output, "\n\nException information:\n", msg.exception
|
19
|
+
output = [output, "\n\nException information:\n", msg.exception[:exc_class], ": ", msg.exception[:exc_message], "\n"]
|
20
20
|
|
21
|
-
backtrace = backtrace = msg.exception
|
21
|
+
backtrace = backtrace = msg.exception[:exc_backtrace]
|
22
22
|
if backtrace
|
23
23
|
output += [backtrace.join($/), "\n\n"]
|
24
24
|
else
|
25
25
|
output << "(Backtrace is unavailable)\n\n"
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
output = output.join
|
29
29
|
end
|
30
30
|
return output
|
31
31
|
end
|
32
32
|
end
|
33
|
-
|
34
|
-
|
33
|
+
|
34
|
+
|
35
35
|
class ProcFormatter < Formatter
|
36
36
|
attr_accessor :proc
|
37
37
|
|
@@ -39,12 +39,12 @@ module Logbert
|
|
39
39
|
raise ArgumentError, "ProcFormatter must be initialized with a block" unless block_given?
|
40
40
|
@proc = block
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
43
|
def format(msg)
|
44
44
|
@proc.call msg
|
45
45
|
end
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
def self.fmt(&block)
|
49
49
|
ProcFormatter.new(&block)
|
50
50
|
end
|