Created
March 20, 2011 16:05
-
-
Save oelmekki/878412 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DebugLogger < Logger | |
def format_message( severity, timestamp, progname, msg ) | |
case true | |
when ( msg.kind_of? Exception ) | |
"#{msg.message}\n#{msg.backtrace.join "\n" }" | |
when ( msg.is_a? String ) | |
"#{msg}\n" | |
else | |
msg.inspect | |
end | |
end | |
end | |
module Kernel | |
def debug_log( msg ) | |
unless defined? @@debug_file | |
@@debug_file = File.open( Rails.root.to_s + '/log/debug.log', 'a' ) | |
@@debug_file.sync = true | |
end | |
@@debug_logger ||= DebugLogger.new( @@debug_file ) | |
@@debug_logger.debug msg | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment