Class: RunLoop::Logging
- Inherits:
-
Object
- Object
- RunLoop::Logging
- Defined in:
- lib/run_loop/logging.rb
Class Method Summary collapse
- .debug_puts(msg) ⇒ Object
- .log_debug(logger, message) ⇒ Object
- .log_header(logger, message) ⇒ Object
- .log_info(logger, message) ⇒ Object
- .log_level(level, logger, message) ⇒ Object
Class Method Details
.debug_puts(msg) ⇒ Object
31 32 33 |
# File 'lib/run_loop/logging.rb', line 31 def self.debug_puts(msg) puts msg if RunLoop::Environment.debug? end |
.log_debug(logger, message) ⇒ Object
8 9 10 |
# File 'lib/run_loop/logging.rb', line 8 def self.log_debug(logger, ) log_level :debug, logger, end |
.log_header(logger, message) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/run_loop/logging.rb', line 12 def self.log_header(logger, ) msg = "\n\e[#{35}m### #{} ###\e[0m" if logger.respond_to?(:debug) logger.debug(msg) else debug_puts(msg) end end |
.log_info(logger, message) ⇒ Object
4 5 6 |
# File 'lib/run_loop/logging.rb', line 4 def self.log_info(logger, ) log_level :info, logger, end |
.log_level(level, logger, message) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/run_loop/logging.rb', line 21 def self.log_level(level, logger, ) level = level.to_sym msg = "#{Time.now} [RunLoop:#{level}]: #{}" if logger.respond_to?(level) logger.send(level, msg) else debug_puts(msg) end end |