Class: Dorothy::DoroLogger
- Inherits:
-
Logger
- Object
- Logger
- Dorothy::DoroLogger
- Defined in:
- lib/dorothy2/do-logger.rb
Overview
The original Logger has a little bug that prevent me to add the progname while using warn,error,etc methods
Instance Method Summary collapse
- #debug(progname, text, &block) ⇒ Object
- #error(progname, text, &block) ⇒ Object
- #fatal(progname, text, &block) ⇒ Object
- #info(progname, text, &block) ⇒ Object
-
#initialize(logdev, shift_age = 0, shift_size = 1048576) ⇒ DoroLogger
constructor
A new instance of DoroLogger.
- #warn(progname, text, &block) ⇒ Object
Constructor Details
#initialize(logdev, shift_age = 0, shift_size = 1048576) ⇒ DoroLogger
Returns a new instance of DoroLogger.
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/dorothy2/do-logger.rb', line 8 def initialize(logdev, shift_age = 0, shift_size = 1048576) if logdev != STDOUT unless Util.exists? logdev FileUtils.touch(logdev) end end super(logdev, shift_age, shift_size) @formatter = proc do |severity, datetime, progname, msg| "[#{datetime.strftime('%d/%m/%Y %H:%M:%S')}] #{severity =~ /ERROR|FATAL/ ? severity.red : severity} [#{progname.yellow}] #{msg}\n" end end |
Instance Method Details
#debug(progname, text, &block) ⇒ Object
22 23 24 |
# File 'lib/dorothy2/do-logger.rb', line 22 def debug(progname, text, &block) add(DEBUG, text, progname, &block) if VERBOSE end |
#error(progname, text, &block) ⇒ Object
30 31 32 |
# File 'lib/dorothy2/do-logger.rb', line 30 def error(progname, text, &block) add(ERROR, text, progname, &block) end |
#fatal(progname, text, &block) ⇒ Object
34 35 36 |
# File 'lib/dorothy2/do-logger.rb', line 34 def fatal(progname, text, &block) add(FATAL, text, progname, &block) end |
#info(progname, text, &block) ⇒ Object
38 39 40 |
# File 'lib/dorothy2/do-logger.rb', line 38 def info(progname, text, &block) add(INFO, text, progname, &block) end |
#warn(progname, text, &block) ⇒ Object
26 27 28 |
# File 'lib/dorothy2/do-logger.rb', line 26 def warn(progname, text, &block) add(WARN, text, progname, &block) end |