Class: Flare::Util::Log4rLogger
- Defined in:
- lib/flare/util/log4r_logger.rb
Overview
Description
Log4rLogger is a custom logging class for log4r
Constant Summary collapse
- @@formatter =
Log4r::PatternFormatter.new( :pattern => "%d %C[%l]: %M", :date_format => "%Y/%m/%d %H:%M:%S" )
- @@console_formatter =
Log4r::PatternFormatter.new( :pattern => "%M", :date_format => "%Y/%m/%d %H:%M:%S" )
Instance Method Summary collapse
- #console? ⇒ Boolean
- #debug(msg) ⇒ Object
- #error(msg) ⇒ Object
- #fatal(msg) ⇒ Object
- #info(msg) ⇒ Object
-
#initialize(logger) ⇒ Log4rLogger
constructor
A new instance of Log4rLogger.
- #trace(msg) ⇒ Object
- #warn(msg) ⇒ Object
Constructor Details
#initialize(logger) ⇒ Log4rLogger
Returns a new instance of Log4rLogger.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/flare/util/log4r_logger.rb', line 25 def initialize(logger) if logger.nil? outputter = Log4r::StdoutOutputter.new( "console", :formatter => @@console_formatter ) logger = Log4r::Logger.new($0) logger.level = Log4r::INFO logger.add(outputter) elsif logger.instance_of?(String) outputter = Log4r::FileOutputter.new( "file", :filename => logger, :trunc => false, :formatter => @@formatter ) logger = Log4r::Logger.new($0) logger.level = Log4r::INFO logger.add(outputter) end @logger = logger end |
Instance Method Details
#console? ⇒ Boolean
72 73 74 |
# File 'lib/flare/util/log4r_logger.rb', line 72 def console? @logger.instance_of?(Log4r::StdoutOutputter) || @logger.instance_of?(Log4r::StderrOutputter) end |
#debug(msg) ⇒ Object
68 69 70 |
# File 'lib/flare/util/log4r_logger.rb', line 68 def debug(msg) @logger.debug(msg) end |
#error(msg) ⇒ Object
60 61 62 |
# File 'lib/flare/util/log4r_logger.rb', line 60 def error(msg) @logger.error(msg) end |
#fatal(msg) ⇒ Object
64 65 66 |
# File 'lib/flare/util/log4r_logger.rb', line 64 def fatal(msg) @logger.fatal(msg) end |
#info(msg) ⇒ Object
48 49 50 |
# File 'lib/flare/util/log4r_logger.rb', line 48 def info(msg) @logger.info(msg) end |
#trace(msg) ⇒ Object
56 57 58 |
# File 'lib/flare/util/log4r_logger.rb', line 56 def trace(msg) @logger.debug(msg) end |
#warn(msg) ⇒ Object
52 53 54 |
# File 'lib/flare/util/log4r_logger.rb', line 52 def warn(msg) @logger.warn(msg) end |