class AC::Logger::Instance
Public Class Methods
new(out = nil, level = ::Logger::WARN)
click to toggle source
Calls superclass method
# File lib/ac/logger.rb, line 33 def initialize out = nil, level = ::Logger::WARN super(out || default_outstream) self.level = level end
Public Instance Methods
default_outstream()
click to toggle source
default output is STDOUT for rails test and non-rails apps, to a logfile otherwise
# File lib/ac/logger.rb, line 21 def default_outstream if ! (Object.const_defined? 'Rails') STDOUT else if 'test' === ::Rails.env STDOUT else "#{::Rails.root.to_s}/log/#{::Rails.env}.log" end end end
ex(e, msg = nil, level = :error)
click to toggle source
exception convenience function with callstack logging:
Log.ex e
does actually do:
Log.error e Log.debug "#{e.backtrace.join "\n\t"}"
and:
Log.ex e, "some message here"
stands for:
Log.error "some message here" Log.debug "#{e.backtrace.join "\n\t"}"
# File lib/ac/logger.rb, line 58 def ex(e, msg = nil, level = :error) __send__ level, "#{e}: #{msg}" debug "#{e} -> (callstack):\n\t#{e.backtrace.join "\n\t"}" end
format_message(severity, ts, progname, msg)
click to toggle source
this is to de-patch the rails formatting patch..
# File lib/ac/logger.rb, line 39 def format_message(severity, ts, progname, msg) "#{ts.strftime '%Y-%m-%d %H:%M:%S'} #{severity.chars.first} #{msg}\n" end