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
-
.debug(msg) ⇒ Object
: (untyped) -> void.
-
.error(msg) ⇒ Object
: (untyped) -> void.
-
.info(msg) ⇒ Object
: (untyped) -> void.
-
.warn(msg) ⇒ Object
: (untyped) -> void.
Instance Method Summary collapse
-
#debug(msg) ⇒ Object
: (untyped) -> void.
-
#debug_mode? ⇒ Boolean
: () -> bool.
-
#error(msg) ⇒ Object
: (untyped) -> void.
-
#initialize ⇒ MultiLogger
constructor
: () -> void.
-
#warn(msg) ⇒ Object
: (untyped) -> void.
Constructor Details
#initialize ⇒ MultiLogger
: () -> void
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/fusuma/multi_logger.rb', line 40 def initialize filepath = self.class.instance_variable_get(:@filepath) if filepath logfile = File.new(filepath, "a") logfile.sync = true 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
16 17 18 |
# File 'lib/fusuma/multi_logger.rb', line 16 def filepath=(value) @filepath = value end |
Instance Attribute Details
#debug_mode ⇒ Object
Returns the value of attribute debug_mode.
13 14 15 |
# File 'lib/fusuma/multi_logger.rb', line 13 def debug_mode @debug_mode end |
#err_logger ⇒ Object (readonly)
Returns the value of attribute err_logger.
12 13 14 |
# File 'lib/fusuma/multi_logger.rb', line 12 def err_logger @err_logger end |
Class Method Details
.debug(msg) ⇒ Object
: (untyped) -> void
24 25 26 |
# File 'lib/fusuma/multi_logger.rb', line 24 def debug(msg) instance.debug(msg) end |
.error(msg) ⇒ Object
: (untyped) -> void
34 35 36 |
# File 'lib/fusuma/multi_logger.rb', line 34 def error(msg) instance.error(msg) end |
.info(msg) ⇒ Object
: (untyped) -> void
19 20 21 |
# File 'lib/fusuma/multi_logger.rb', line 19 def info(msg) instance.info(msg) end |
.warn(msg) ⇒ Object
: (untyped) -> void
29 30 31 |
# File 'lib/fusuma/multi_logger.rb', line 29 def warn(msg) instance.warn(msg) end |
Instance Method Details
#debug(msg) ⇒ Object
: (untyped) -> void
55 56 57 58 59 60 61 |
# File 'lib/fusuma/multi_logger.rb', line 55 def debug(msg) return unless debug_mode? return if ignore_pattern?(msg) super end |
#debug_mode? ⇒ Boolean
: () -> bool
74 75 76 |
# File 'lib/fusuma/multi_logger.rb', line 74 def debug_mode? debug_mode end |
#error(msg) ⇒ Object
: (untyped) -> void
69 70 71 |
# File 'lib/fusuma/multi_logger.rb', line 69 def error(msg) err_logger.error(msg) end |
#warn(msg) ⇒ Object
: (untyped) -> void
64 65 66 |
# File 'lib/fusuma/multi_logger.rb', line 64 def warn(msg) err_logger.warn(msg) end |