hatchet 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/hatchet/hatchet_logger.rb +5 -1
- data/lib/hatchet/logger_appender.rb +0 -1
- data/lib/hatchet/version.rb +1 -1
- data/spec/helpers/disabled_appender.rb +16 -0
- data/spec/logger_spec.rb +8 -1
- data/spec/spec_helper.rb +1 -0
- data/spec/standard_formatter_spec.rb +0 -14
- metadata +3 -1
@@ -96,7 +96,11 @@ module Hatchet
|
|
96
96
|
# Returns nothing.
|
97
97
|
#
|
98
98
|
def add(level, message)
|
99
|
-
@appenders.each
|
99
|
+
@appenders.each do |appender|
|
100
|
+
if appender.enabled?(level, @context)
|
101
|
+
appender.add(level, @context, message)
|
102
|
+
end
|
103
|
+
end
|
100
104
|
end
|
101
105
|
|
102
106
|
# Private: Determines the contextual name of the host object.
|
data/lib/hatchet/version.rb
CHANGED
data/spec/logger_spec.rb
CHANGED
@@ -3,8 +3,9 @@
|
|
3
3
|
require_relative 'spec_helper'
|
4
4
|
|
5
5
|
describe HatchetLogger do
|
6
|
+
let(:disabled_appender) { DisabledAppender.new }
|
6
7
|
let(:appender) { StoringAppender.new :debug }
|
7
|
-
let(:appenders) { [appender] }
|
8
|
+
let(:appenders) { [appender, disabled_appender] }
|
8
9
|
let(:context) { Context::Class.new }
|
9
10
|
let(:subject) { HatchetLogger.new context, appenders }
|
10
11
|
|
@@ -29,6 +30,12 @@ describe HatchetLogger do
|
|
29
30
|
assert context.class == received.context
|
30
31
|
assert message == received.message.to_s
|
31
32
|
end
|
33
|
+
|
34
|
+
it 'should not call the disabled appender' do
|
35
|
+
subject.send level, message
|
36
|
+
|
37
|
+
refute disabled_appender.add_called
|
38
|
+
end
|
32
39
|
end
|
33
40
|
end
|
34
41
|
|
data/spec/spec_helper.rb
CHANGED
@@ -3,20 +3,6 @@
|
|
3
3
|
require_relative 'spec_helper'
|
4
4
|
require 'date'
|
5
5
|
|
6
|
-
describe SimpleFormatter do
|
7
|
-
let(:subject) { SimpleFormatter.new }
|
8
|
-
|
9
|
-
describe 'when formatting a message' do
|
10
|
-
before do
|
11
|
-
@message = subject.format(:info, 'Custom::Context', 'Hello, World')
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'outputs the message in the LEVEL CONTEXT - MESSAGE format' do
|
15
|
-
assert 'INFO - Custom::Context - Hello, World' == @message, "got #{@message}"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
6
|
describe StandardFormatter do
|
21
7
|
TIME_FORMAT = '%Y-%m-%d %H:%M:%S.%L'
|
22
8
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hatchet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -30,6 +30,7 @@ files:
|
|
30
30
|
- lib/hatchet/version.rb
|
31
31
|
- lib/hatchet.rb
|
32
32
|
- spec/configuration_spec.rb
|
33
|
+
- spec/helpers/disabled_appender.rb
|
33
34
|
- spec/helpers/logger_double.rb
|
34
35
|
- spec/helpers/storing_appender.rb
|
35
36
|
- spec/helpers/test_formatter.rb
|
@@ -67,6 +68,7 @@ specification_version: 3
|
|
67
68
|
summary: Logging library that provides the ability to add class/module specific filters
|
68
69
|
test_files:
|
69
70
|
- spec/configuration_spec.rb
|
71
|
+
- spec/helpers/disabled_appender.rb
|
70
72
|
- spec/helpers/logger_double.rb
|
71
73
|
- spec/helpers/storing_appender.rb
|
72
74
|
- spec/helpers/test_formatter.rb
|