improved_logging 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG.md CHANGED
@@ -1,7 +1,11 @@
1
+ # 1.0.2
2
+
3
+ * Added support for yielding to message block if passed to warn or error methods
4
+
1
5
  # 1.0.1
2
6
 
3
- * Remove explicit dependency requirements
7
+ * Remove explicit dependency requirements
4
8
 
5
9
  # 1.0.0
6
10
 
7
- * Initial release
11
+ * Initial release
@@ -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
@@ -1,3 +1,3 @@
1
1
  module ImprovedLogging
2
- VERSION = '1.0.1'
2
+ VERSION = '1.0.2'
3
3
  end
@@ -41,4 +41,16 @@ describe ActiveSupport::BufferedLogger do
41
41
  @logger.warn('message', e)
42
42
  end
43
43
  end
44
- end
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
@@ -3,6 +3,6 @@ require 'improved_logging/version'
3
3
 
4
4
  describe ImprovedLogging do
5
5
  it "should be the correct version" do
6
- ImprovedLogging::VERSION.should == '1.0.1'
6
+ ImprovedLogging::VERSION.should == '1.0.2'
7
7
  end
8
8
  end
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.1
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-01 00:00:00 Z
13
+ date: 2011-09-26 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport