Class: Gom::Logger
- Inherits:
-
Logger
- Object
- Logger
- Gom::Logger
- Defined in:
- lib/gom/logger.rb
Constant Summary collapse
- Levels =
Gom::Log.level = Gom::Attribute.value(“/gom/log:level”, ::Logger::INFO)
{ "debug" => ::Logger::DEBUG, "info" => ::Logger::INFO, "warn" => ::Logger::WARN, "error" => ::Logger::ERROR, "fatal" => ::Logger::FATAL, }
Instance Method Summary collapse
-
#default_outstream ⇒ Object
output defaults to STDOUT for rails test and non-rails apps, to a logfile otherwise.
-
#ex(e, msg = nil, level = :error) ⇒ Object
experimental convenience function:.
-
#format_message(severity, timestamp, progname, msg) ⇒ Object
this is to de-patch the rails formatting patch..
-
#initialize(out = nil) ⇒ Logger
constructor
A new instance of Logger.
Constructor Details
#initialize(out = nil) ⇒ Logger
Returns a new instance of Logger.
32 33 34 35 |
# File 'lib/gom/logger.rb', line 32 def initialize out = nil super(out || default_outstream) self.level = ::Logger::DEBUG end |
Instance Method Details
#default_outstream ⇒ Object
output defaults to STDOUT for rails test and non-rails apps, to a logfile otherwise
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/gom/logger.rb', line 20 def default_outstream if ! (Object.const_defined? 'Rails') STDOUT else if 'test' === ::Rails.env STDOUT else "#{::Rails.root.to_s}/log/gom-#{::Rails.env}.log" end end end |
#ex(e, msg = nil, level = :error) ⇒ Object
experimental convenience function:
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"}"
57 58 59 60 |
# File 'lib/gom/logger.rb', line 57 def ex e, msg = nil, level = :error send level, "#{e}: #{(msg || e)}" debug "#{e} -- callstack: #{msg}\n\t#{e.backtrace.join "\n\t"}" end |
#format_message(severity, timestamp, progname, msg) ⇒ Object
this is to de-patch the rails formatting patch..
38 39 40 |
# File 'lib/gom/logger.rb', line 38 def (severity, , progname, msg) "#{.strftime '%Y-%m-%d %H:%M:%S'} #{severity.chars.first} #{msg}\n" end |