Skip to content

Instantly share code, notes, and snippets.

@oelmekki
Created March 20, 2011 13:29
Show Gist options
  • Save oelmekki/878327 to your computer and use it in GitHub Desktop.
Save oelmekki/878327 to your computer and use it in GitHub Desktop.
class DebugLogger < Logger
def format_message( severity, timestamp, progname, msg )
if msg.is_a? String
"#{msg}\n"
else
"#{msg.message}\n#{msg.backtrace.join "\n" }"
end
end
end
module Kernel
def debug( 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