hatchet 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -96,7 +96,11 @@ module Hatchet
96
96
  # Returns nothing.
97
97
  #
98
98
  def add(level, message)
99
- @appenders.each { |appender| appender.add(level, @context, message) }
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.
@@ -65,7 +65,6 @@ module Hatchet
65
65
  # Returns nothing.
66
66
  #
67
67
  def add(level, context, message)
68
- return unless enabled? level, context
69
68
  @logger.send level, @formatter.format(level, context, message)
70
69
  end
71
70
 
@@ -4,6 +4,6 @@ module Hatchet
4
4
 
5
5
  # Public: The version of Hatchet.
6
6
  #
7
- VERSION = '0.0.8'
7
+ VERSION = '0.0.9'
8
8
 
9
9
  end
@@ -0,0 +1,16 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ class DisabledAppender
4
+
5
+ attr_reader :add_called
6
+
7
+ def enabled?(level, context)
8
+ false
9
+ end
10
+
11
+ def add(level, context, message)
12
+ @add_called = true
13
+ end
14
+
15
+ end
16
+
@@ -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
 
@@ -9,6 +9,7 @@ include Hatchet
9
9
 
10
10
  require_relative 'helpers/logger_double'
11
11
  require_relative 'helpers/test_formatter'
12
+ require_relative 'helpers/disabled_appender'
12
13
  require_relative 'helpers/storing_appender'
13
14
 
14
15
  INITIAL_EXECUTION_CONTEXT = self
@@ -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.8
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