Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

Logger#log_error prints to STDERR
  • Loading branch information...
commit 54799d765461f70b791eb6dc47898f2f1389733d 2 parents 90b2f2c + e42bd3f
Marc-André Cournoyer authored June 02, 2011
4  lib/thin/logging.rb
@@ -46,9 +46,9 @@ def debug(msg=nil)
46 46
     
47 47
     # Log an error backtrace if debugging is activated
48 48
     def log_error(e=$!)
49  
-      debug "#{e}\n\t" + e.backtrace.join("\n\t")
  49
+      STDERR.print("#{e}\n\t" + e.backtrace.join("\n\t")) if Logging.debug?
50 50
     end
51 51
     module_function :log_error
52 52
     public :log_error
53 53
   end
54  
-end
  54
+end
8  spec/logging_spec.rb
@@ -39,8 +39,14 @@ class TestLogging
39 39
     Logging.silent = true
40 40
     Logging.log "hi"
41 41
   end
  42
+
  43
+  it "should print errors to STDERR" do
  44
+    error = mock(:error, :backtrace => Array("PC LOAD LETTER"))
  45
+    STDERR.should_receive(:print).with(/PC LOAD LETTER/)
  46
+    @object.log_error(error)
  47
+  end
42 48
   
43 49
   after do
44 50
     Logging.silent = true
45 51
   end
46  
-end
  52
+end

0 notes on commit 54799d7

Please sign in to comment.
Something went wrong with that request. Please try again.