lager 1.0.0.1 → 1.0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/lager.rb +9 -5
- data/test/lager.rb +3 -3
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.0.
|
1
|
+
1.0.0.3
|
data/lib/lager.rb
CHANGED
@@ -54,11 +54,12 @@ module Lager
|
|
54
54
|
level ||= (defined?(@lager) ? @lager.level : :warn)
|
55
55
|
@lager = Logger.new dest
|
56
56
|
@lager.formatter = proc { |sev, time, progname, msg|
|
57
|
-
line = "[#{time.strftime('%Y-%m-%d %H:%M:%S')}]
|
58
|
-
line <<
|
59
|
-
line <<
|
57
|
+
line = "[#{time.strftime('%Y-%m-%d %H:%M:%S')}]"
|
58
|
+
line << sev.to_s.upcase.rjust(5) << ":"
|
59
|
+
line << "(#{progname})" if progname
|
60
|
+
line << " #{msg}\n"
|
60
61
|
}
|
61
|
-
log_level level
|
62
|
+
log_level = level
|
62
63
|
dest # don't expose @lager here
|
63
64
|
end
|
64
65
|
|
@@ -68,7 +69,10 @@ module Lager
|
|
68
69
|
#
|
69
70
|
def log_level(level = nil)
|
70
71
|
raise "no @lager available" unless defined?(@lager)
|
71
|
-
|
72
|
+
if level
|
73
|
+
@lager.warn { "passing an argument to log_level is deprecated" }
|
74
|
+
return self.log_level = level
|
75
|
+
end
|
72
76
|
[:debug, :info, :warn, :error, :fatal][@lager.level] || :unknown
|
73
77
|
end
|
74
78
|
|
data/test/lager.rb
CHANGED
@@ -31,7 +31,7 @@ describe Lager do
|
|
31
31
|
l = Logger.new($stderr)
|
32
32
|
Foo.log_to l
|
33
33
|
Foo.lager.must_equal l
|
34
|
-
Foo.log_level :info
|
34
|
+
Foo.log_level = :info
|
35
35
|
Foo.bar # does debug logging, should be silent
|
36
36
|
Foo.lager.must_equal l
|
37
37
|
end
|
@@ -39,7 +39,7 @@ describe Lager do
|
|
39
39
|
it "must handle a Tempfile when provided" do
|
40
40
|
t = Tempfile.new('lager')
|
41
41
|
Foo.log_to t
|
42
|
-
Foo.log_level :debug
|
42
|
+
Foo.log_level = :debug
|
43
43
|
Foo.bar # does debug logging
|
44
44
|
t.rewind
|
45
45
|
t.read.wont_be_empty
|
@@ -50,7 +50,7 @@ describe Lager do
|
|
50
50
|
it "must handle a path to /tmp when provided" do
|
51
51
|
fname = '/tmp/lager.log'
|
52
52
|
Foo.log_to fname
|
53
|
-
Foo.log_level :debug
|
53
|
+
Foo.log_level = :debug
|
54
54
|
Foo.bar # does debug logging
|
55
55
|
Foo.log_to $stderr
|
56
56
|
File.exists?(fname).must_equal true
|