Permalink
Browse files

Merge pull request #57 from textgoeshere/log-errors-to-stderr

Logger#log_error prints to STDERR
  • Loading branch information...
macournoyer committed Jun 2, 2011
2 parents 90b2f2c + e42bd3f commit 54799d765461f70b791eb6dc47898f2f1389733d
Showing with 9 additions and 3 deletions.
  1. +2 −2 lib/thin/logging.rb
  2. +7 −1 spec/logging_spec.rb
View
@@ -46,9 +46,9 @@ def debug(msg=nil)
# Log an error backtrace if debugging is activated
def log_error(e=$!)
- debug "#{e}\n\t" + e.backtrace.join("\n\t")
+ STDERR.print("#{e}\n\t" + e.backtrace.join("\n\t")) if Logging.debug?
end
module_function :log_error
public :log_error
end
-end
+end
View
@@ -39,8 +39,14 @@ class TestLogging
Logging.silent = true
Logging.log "hi"
end
+
+ it "should print errors to STDERR" do
+ error = mock(:error, :backtrace => Array("PC LOAD LETTER"))
+ STDERR.should_receive(:print).with(/PC LOAD LETTER/)
+ @object.log_error(error)
+ end
after do
Logging.silent = true
end
-end
+end

0 comments on commit 54799d7

Please sign in to comment.