madvertise-logging 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -132,9 +132,12 @@ module Madvertise
132
132
  #
133
133
  # @param [Exception, String] exc The exception to log. If exc is a
134
134
  # String no backtrace will be generated.
135
- def exception(exc)
136
- exc = "EXCEPTION: #{exc.message}: #{clean_trace(exc.backtrace)}" if exc.is_a?(::Exception)
137
- add(:fatal, exc, true)
135
+ # @param [String] prefix Additional message to log.
136
+ def exception(exc, prefix=nil)
137
+ msg = "EXCEPTION"
138
+ msg << ": #{prefix}" if prefix
139
+ msg << ": #{exc.message}: #{clean_trace(exc.backtrace)}" if exc.is_a?(::Exception)
140
+ fatal(msg)
138
141
  end
139
142
 
140
143
  # Save the current token and associate it with obj#object_id.
@@ -188,11 +191,10 @@ module Madvertise
188
191
  [ File.basename(file), num ].join(':')
189
192
  end
190
193
 
191
- def add(severity, message, skip_caller = false)
194
+ def add(severity, message)
192
195
  severity = self.class.severities[severity]
193
- message = "#{called_from}: #{message}" unless skip_caller
196
+ message = "#{called_from}: #{message}"
194
197
  message = "[#{@token}] #{message}" if @token
195
-
196
198
  logger.add(severity) { message }
197
199
  return nil
198
200
  end
@@ -279,6 +281,7 @@ module Madvertise
279
281
  end
280
282
  end
281
283
 
284
+ # @private
282
285
  module IOCompat
283
286
  def close_read
284
287
  nil
@@ -1,6 +1,6 @@
1
1
  module Madvertise
2
2
  module Logging
3
3
  # @private
4
- VERSION = "0.5.0"
4
+ VERSION = "0.6.0"
5
5
  end
6
6
  end
@@ -71,7 +71,6 @@ describe ImprovedLogger do
71
71
 
72
72
  it "should log fatal level messages" do
73
73
  @logger.fatal("Fatal test")
74
-
75
74
  @logfile.should have_received_message(/\[FATAL\].*Fatal test/)
76
75
  end
77
76
 
@@ -117,6 +116,19 @@ describe ImprovedLogger do
117
116
  @logfile.should_not have_received_message("EXCEPTION:")
118
117
  end
119
118
 
119
+ it "should log additional info on exceptions" do
120
+ fake_trace = [
121
+ "/home/jdoe/app/libexec/app.rb:1:in `foo'",
122
+ "/usr/lib/ruby/gems/1.8/gems/madvertise-logging-0.1.0/lib/madvertise/logging/improved_logger.rb:42: in `info'"
123
+ ]
124
+
125
+ e = RuntimeError.new('Test error')
126
+ e.set_backtrace(fake_trace)
127
+
128
+ @logger.exception(e, "app failed to foo")
129
+ @logfile.should have_received_message("app failed to foo")
130
+ end
131
+
120
132
  it "should support silencing" do
121
133
  @logger.silence do |logger|
122
134
  logger.info "This should never be logged"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: madvertise-logging
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
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-08-22 00:00:00.000000000 Z
12
+ date: 2012-09-11 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Advanced logging classes with buffer backend, transactions, multi logger,
15
15
  etc
@@ -55,7 +55,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
55
55
  version: '0'
56
56
  segments:
57
57
  - 0
58
- hash: 3990327644738544266
58
+ hash: -1250046391813060871
59
59
  required_rubygems_version: !ruby/object:Gem::Requirement
60
60
  none: false
61
61
  requirements:
@@ -64,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
64
64
  version: '0'
65
65
  segments:
66
66
  - 0
67
- hash: 3990327644738544266
67
+ hash: -1250046391813060871
68
68
  requirements: []
69
69
  rubyforge_project:
70
70
  rubygems_version: 1.8.17