hatchet 0.0.14 → 0.0.15
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/hatchet/hatchet_logger.rb +24 -1
- data/lib/hatchet/level_manager.rb +3 -7
- data/lib/hatchet/version.rb +1 -1
- data/lib/hatchet.rb +2 -0
- data/spec/configuration_spec.rb +1 -1
- data/spec/level_manager_spec.rb +1 -1
- metadata +1 -1
@@ -41,6 +41,16 @@ module Hatchet
|
|
41
41
|
#
|
42
42
|
class HatchetLogger
|
43
43
|
|
44
|
+
# Internal: Map from standard library levels to Symbols.
|
45
|
+
#
|
46
|
+
STANDARD_TO_SYMBOL = {
|
47
|
+
Logger::DEBUG => :debug,
|
48
|
+
Logger::INFO => :info,
|
49
|
+
Logger::WARN => :warn,
|
50
|
+
Logger::ERROR => :error,
|
51
|
+
Logger::FATAL => :fatal
|
52
|
+
}
|
53
|
+
|
44
54
|
# Internal: Creates a new logger.
|
45
55
|
#
|
46
56
|
# host - The object the logger gains its context from.
|
@@ -87,6 +97,12 @@ module Hatchet
|
|
87
97
|
|
88
98
|
end
|
89
99
|
|
100
|
+
# Public: Returns the default level of the logger's configuration.
|
101
|
+
#
|
102
|
+
def level
|
103
|
+
@configuration.default_level
|
104
|
+
end
|
105
|
+
|
90
106
|
# Public: Set the lowest level of message to log by default.
|
91
107
|
#
|
92
108
|
# level - The lowest level of message to log by default.
|
@@ -97,7 +113,14 @@ module Hatchet
|
|
97
113
|
# Returns nothing.
|
98
114
|
#
|
99
115
|
def level=(level)
|
100
|
-
|
116
|
+
level = case level
|
117
|
+
when Symbol
|
118
|
+
level
|
119
|
+
else
|
120
|
+
STANDARD_TO_SYMBOL[level] || :info
|
121
|
+
end
|
122
|
+
|
123
|
+
@configuration.level level
|
101
124
|
end
|
102
125
|
|
103
126
|
private
|
@@ -44,14 +44,10 @@ module Hatchet
|
|
44
44
|
clear_levels_cache!
|
45
45
|
end
|
46
46
|
|
47
|
-
#
|
47
|
+
# Internal: Returns the default level of the configuration.
|
48
48
|
#
|
49
|
-
|
50
|
-
|
51
|
-
# Returns nothing.
|
52
|
-
#
|
53
|
-
def level=(level)
|
54
|
-
self.level(level)
|
49
|
+
def default_level
|
50
|
+
self.levels[nil]
|
55
51
|
end
|
56
52
|
|
57
53
|
# Internal: Returns true if the appender is configured to log messages of
|
data/lib/hatchet/version.rb
CHANGED
data/lib/hatchet.rb
CHANGED
data/spec/configuration_spec.rb
CHANGED
data/spec/level_manager_spec.rb
CHANGED
@@ -64,7 +64,7 @@ describe LevelManager do
|
|
64
64
|
describe 'altering the default level' do
|
65
65
|
it 'alters the enabled level for subsequent calls' do
|
66
66
|
assert @manager.enabled?(:info, 'Foo::Bar')
|
67
|
-
@manager.level
|
67
|
+
@manager.level :fatal
|
68
68
|
refute @manager.enabled?(:info, 'Foo::Bar')
|
69
69
|
end
|
70
70
|
end
|