improved_logging 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +6 -2
- data/lib/improved_logging/improved_logging.rb +4 -2
- data/lib/improved_logging/version.rb +1 -1
- data/spec/improved_logging_spec.rb +13 -1
- data/spec/version_spec.rb +1 -1
- metadata +2 -2
data/CHANGELOG.md
CHANGED
@@ -123,12 +123,14 @@ module ImprovedLogging
|
|
123
123
|
|
124
124
|
# add an optional second parameter to the error & warn methods to allow a stack trace:
|
125
125
|
|
126
|
-
def error_with_exception_param(message, exception = nil)
|
126
|
+
def error_with_exception_param(message = '', exception = nil)
|
127
|
+
message = yield if block_given?
|
127
128
|
message += "\n#{exception.inspect}\n#{exception.backtrace.join("\n")}" if exception
|
128
129
|
error_without_exception_param(message)
|
129
130
|
end
|
130
131
|
|
131
|
-
def warn_with_exception_param(message, exception = nil)
|
132
|
+
def warn_with_exception_param(message = '', exception = nil)
|
133
|
+
message = yield if block_given?
|
132
134
|
message += "\n#{exception.inspect}\n#{exception.backtrace.join("\n")}" if exception
|
133
135
|
warn_without_exception_param(message)
|
134
136
|
end
|
@@ -41,4 +41,16 @@ describe ActiveSupport::BufferedLogger do
|
|
41
41
|
@logger.warn('message', e)
|
42
42
|
end
|
43
43
|
end
|
44
|
-
|
44
|
+
|
45
|
+
[:error, :warn].each do |severity|
|
46
|
+
it 'should allow you to pass a block to the error method' do
|
47
|
+
method_sym = "#{severity}_without_exception_param".to_sym
|
48
|
+
@logger.should_receive(method_sym).with('message')
|
49
|
+
begin
|
50
|
+
raise StandardError.new
|
51
|
+
rescue => e
|
52
|
+
@logger.send(severity) { 'message' }
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/spec/version_spec.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: improved_logging
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.0.
|
5
|
+
version: 1.0.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- David Czarnecki
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-09-
|
13
|
+
date: 2011-09-26 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|