hatchet 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -71,8 +71,17 @@ module Hatchet
71
71
  # Public: Returns true if any of the appenders will log messages for the
72
72
  # current context, otherwise returns false.
73
73
  #
74
+ # Writes messages to STDOUT if any appender fails to complete the check.
75
+ #
74
76
  define_method "#{level}?" do
75
- @appenders.any? { |appender| appender.enabled? level, @context }
77
+ @appenders.any? do |appender|
78
+ begin
79
+ appender.enabled? level, @context
80
+ rescue => e
81
+ puts "Failed to check if level #{level} enabled for #{context} with appender #{appender}\n"
82
+ false
83
+ end
84
+ end
76
85
  end
77
86
 
78
87
  end
@@ -93,12 +102,20 @@ module Hatchet
93
102
  # message - The message that will be logged by an appender when it is
94
103
  # configured to log at the given level or lower.
95
104
  #
105
+ # Writes messages to STDOUT if any appender fails to complete the enabled
106
+ # check or log the message.
107
+ #
96
108
  # Returns nothing.
97
109
  #
98
110
  def add(level, message)
99
111
  @appenders.each do |appender|
100
112
  if appender.enabled?(level, @context)
101
- appender.add(level, @context, message)
113
+ begin
114
+ appender.add(level, @context, message)
115
+ rescue => e
116
+ puts "Failed to log message for #{context} with appender #{appender} - #{level} - #{message}\n"
117
+ puts "#{e}\n"
118
+ end
102
119
  end
103
120
  end
104
121
  end
@@ -54,13 +54,11 @@ module Hatchet
54
54
  end
55
55
  end
56
56
 
57
- # Internal: Adds a message to the appender if the appender is configured to
58
- # log messages at the given level for the given context.
57
+ # Internal: Adds a message to the logger.
59
58
  #
60
59
  # level - The level of the message.
61
60
  # context - The context of the message.
62
- # message - The message to add to the appender if it is configured to log
63
- # messages at the given level for the given context.
61
+ # message - The unformatted message.
64
62
  #
65
63
  # Returns nothing.
66
64
  #
@@ -4,6 +4,6 @@ module Hatchet
4
4
 
5
5
  # Public: The version of Hatchet.
6
6
  #
7
- VERSION = '0.0.9'
7
+ VERSION = '0.0.10'
8
8
 
9
9
  end
@@ -27,13 +27,6 @@ describe LoggerAppender do
27
27
  end
28
28
  end
29
29
 
30
- describe 'sending a message for a disabled level' do
31
- it 'does not pass the message on to the logger' do
32
- subject.add :debug, 'Context', 'Hello, World'
33
- assert_empty logger.messages
34
- end
35
- end
36
-
37
30
  describe 'sending a message of an enabled level' do
38
31
  let(:message) { logger.messages.last }
39
32
 
@@ -54,18 +54,22 @@ describe StandardFormatter do
54
54
  end
55
55
  end
56
56
 
57
- describe 'benchmarks' do
58
- it 'is reasonably quick' do
59
- start = Time.now
57
+ if ENV["BENCH"] then
60
58
 
61
- 50_000.times do
62
- subject.format(:info, @context, @message)
63
- end
59
+ describe 'benchmarks' do
60
+ it 'is reasonably quick' do
61
+ start = Time.now
62
+
63
+ 50_000.times do
64
+ subject.format(:info, @context, @message)
65
+ end
64
66
 
65
- took = Time.now - start
66
- limit = 0.4
67
- assert took < limit, "Expected messages to take less than #{limit} but took #{took}"
67
+ took = Time.now - start
68
+ limit = 0.4
69
+ assert took < limit, "Expected messages to take less than #{limit} but took #{took}"
70
+ end
68
71
  end
72
+
69
73
  end
70
74
 
71
75
  def format_as_string(time)
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.9
4
+ version: 0.0.10
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-22 00:00:00.000000000 Z
12
+ date: 2012-07-23 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Logging library that provides the ability to add class/module specific
15
15
  filters