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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b066c7cc2f3688d294e94e5f7825e7a7530de417
4
- data.tar.gz: 02398a4a8ca0bc1c45e30200481d7218f8c95508
3
+ metadata.gz: 5a1e7e4ce05f9f09807de01773a6df70dc9be604
4
+ data.tar.gz: 97de94a8aa17900ead139ea756072137125f8ebd
5
5
  SHA512:
6
- metadata.gz: 63c6ea4b02f46717d9814ed8abf6f4fad0c34202abaaacf1de5dc355ba37ea82f3bb78572ceb712373849ae48738496482b461e4cbebf0fe4e7e5c4070f80720
7
- data.tar.gz: b54ca353d2966fbae2ff428b77c975cae72e63cc754b0707e7889720b68b98d744b08e4ee2facb50482961507bee8ae2fe32067d63e03a312c6397135331f845
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 dest
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 info msg = nil
20
- return unless msg
21
-
22
- puts formatted( msg )
22
+ def debug?
23
+ @level <= LEVELS[ :debug ]
23
24
  end
24
25
 
25
26
  def info?
26
- true
27
+ @level >= LEVELS[ :info ]
27
28
  end
28
29
 
29
- def debug?
30
- true
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
@@ -1,3 +1,3 @@
1
1
  module EnhancedLogger
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enhanced-logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - George Ulmer