Class: Fusuma::MultiLogger
- Inherits:
-
Logger
- Object
- Logger
- Fusuma::MultiLogger
- Includes:
- Singleton
- Defined in:
- lib/fusuma/multi_logger.rb
Overview
logger separate between stdout and strerr
Class Attribute Summary collapse
-
.filepath ⇒ Object
writeonly
Sets the attribute filepath.
Instance Attribute Summary collapse
-
#debug_mode ⇒ Object
Returns the value of attribute debug_mode.
-
#err_logger ⇒ Object
readonly
Returns the value of attribute err_logger.
Class Method Summary collapse
Instance Method Summary collapse
- #debug(msg) ⇒ Object
- #debug_mode? ⇒ Boolean
- #error(msg) ⇒ Object
-
#initialize ⇒ MultiLogger
constructor
A new instance of MultiLogger.
- #warn(msg) ⇒ Object
Constructor Details
#initialize ⇒ MultiLogger
Returns a new instance of MultiLogger.
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/fusuma/multi_logger.rb', line 18 def initialize filepath = self.class.instance_variable_get('@filepath') if filepath logfile = File.new(filepath, 'a') super(logfile) $stderr = logfile else super($stdout) end @err_logger = Logger.new($stderr) @debug_mode = false end |
Class Attribute Details
.filepath=(value) ⇒ Object (writeonly)
Sets the attribute filepath
15 16 17 |
# File 'lib/fusuma/multi_logger.rb', line 15 def filepath=(value) @filepath = value end |
Instance Attribute Details
#debug_mode ⇒ Object
Returns the value of attribute debug_mode.
12 13 14 |
# File 'lib/fusuma/multi_logger.rb', line 12 def debug_mode @debug_mode end |
#err_logger ⇒ Object (readonly)
Returns the value of attribute err_logger.
11 12 13 |
# File 'lib/fusuma/multi_logger.rb', line 11 def err_logger @err_logger end |
Class Method Details
.debug(msg) ⇒ Object
54 55 56 |
# File 'lib/fusuma/multi_logger.rb', line 54 def debug(msg) instance.debug(msg) end |
.error(msg) ⇒ Object
62 63 64 |
# File 'lib/fusuma/multi_logger.rb', line 62 def error(msg) instance.error(msg) end |
.info(msg) ⇒ Object
50 51 52 |
# File 'lib/fusuma/multi_logger.rb', line 50 def info(msg) instance.info(msg) end |
.warn(msg) ⇒ Object
58 59 60 |
# File 'lib/fusuma/multi_logger.rb', line 58 def warn(msg) instance.warn(msg) end |
Instance Method Details
#debug(msg) ⇒ Object
31 32 33 34 35 |
# File 'lib/fusuma/multi_logger.rb', line 31 def debug(msg) return unless debug_mode? super(msg) end |
#debug_mode? ⇒ Boolean
45 46 47 |
# File 'lib/fusuma/multi_logger.rb', line 45 def debug_mode? debug_mode end |
#error(msg) ⇒ Object
41 42 43 |
# File 'lib/fusuma/multi_logger.rb', line 41 def error(msg) err_logger.error(msg) end |
#warn(msg) ⇒ Object
37 38 39 |
# File 'lib/fusuma/multi_logger.rb', line 37 def warn(msg) err_logger.warn(msg) end |