enhanced-logger 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/enhanced_logger/logger.rb +29 -11
- data/lib/enhanced_logger/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a1e7e4ce05f9f09807de01773a6df70dc9be604
|
4
|
+
data.tar.gz: 97de94a8aa17900ead139ea756072137125f8ebd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4da328dce6ea3cb27f49c110fa7f4b16ad3c4e95b74fb0fa9089d9a6a61ac94c2f8dd91c22df4fdf2eebbeabb59abefb2997bf3a427d9a2e32eccebff456250a
|
7
|
+
data.tar.gz: 677953933509c0b343a4337ef9429018ac0c98aa0e1fad2d4826fe546102b262203e6bbcb656adc9157a76a0583e171e42d887176eacc43534f35ae1741bbce0
|
@@ -1,8 +1,11 @@
|
|
1
1
|
module EnhancedLogger
|
2
2
|
class Logger
|
3
|
+
LEVELS = { debug:0, info:1, warn:2, error:3, fatal:4, unknown:5 }.freeze
|
4
|
+
|
3
5
|
attr_accessor :level
|
4
6
|
|
5
|
-
def initialize
|
7
|
+
def initialize level=:info
|
8
|
+
@level = LEVELS[ level ] || LEVELS[ :info ]
|
6
9
|
$stdout.sync = true
|
7
10
|
end
|
8
11
|
|
@@ -16,30 +19,45 @@ module EnhancedLogger
|
|
16
19
|
@remote_request_id = nil
|
17
20
|
end
|
18
21
|
|
19
|
-
def
|
20
|
-
|
21
|
-
|
22
|
-
puts formatted( msg )
|
22
|
+
def debug?
|
23
|
+
@level <= LEVELS[ :debug ]
|
23
24
|
end
|
24
25
|
|
25
26
|
def info?
|
26
|
-
|
27
|
+
@level >= LEVELS[ :info ]
|
27
28
|
end
|
28
29
|
|
29
|
-
def
|
30
|
-
|
30
|
+
def warn?
|
31
|
+
@level <= LEVELS[ :warn ]
|
32
|
+
end
|
33
|
+
|
34
|
+
def error?
|
35
|
+
@level <= LEVELS[ :error ]
|
31
36
|
end
|
32
37
|
|
38
|
+
def fatal?
|
39
|
+
@level <= LEVELS[ :fatal ]
|
40
|
+
end
|
41
|
+
|
42
|
+
|
33
43
|
def debug msg
|
34
|
-
puts formatted( msg )
|
44
|
+
puts formatted( msg ) if debug?
|
45
|
+
end
|
46
|
+
|
47
|
+
def info msg = nil
|
48
|
+
puts formatted( msg ) if info?
|
49
|
+
end
|
50
|
+
|
51
|
+
def warn msg
|
52
|
+
puts formatted( msg ) if warn?
|
35
53
|
end
|
36
54
|
|
37
55
|
def error msg
|
38
|
-
puts formatted( msg )
|
56
|
+
puts formatted( msg ) if error?
|
39
57
|
end
|
40
58
|
|
41
59
|
def fatal msg
|
42
|
-
puts formatted( msg )
|
60
|
+
puts formatted( msg ) if fatal?
|
43
61
|
end
|
44
62
|
|
45
63
|
def formatter
|