Module: CountingSemaphore::NullLogger
Overview
A null logger that discards all log messages. Provides the same interface as a real logger but does nothing. Only yields blocks when ENV is set to “yes”, which is useful in testing. Block form for Logger calls allows you to skip block evaluation if the Logger level is higher than your call, and thus bugs can nest in those Logger blocks. During testing it is helpful to excercise those blocks unconditionally.
Instance Method Summary collapse
-
#debug(message = nil) { ... } ⇒ nil
Logs a debug message.
-
#error(message = nil) { ... } ⇒ nil
Logs an error message.
-
#fatal(message = nil) { ... } ⇒ nil
Logs a fatal message.
-
#info(message = nil) { ... } ⇒ nil
Logs an info message.
-
#warn(message = nil) { ... } ⇒ nil
Logs a warning message.
Instance Method Details
#debug(message = nil) { ... } ⇒ nil
Logs a debug message. Discards the message but may yield the block for testing.
17 18 19 |
# File 'lib/counting_semaphore/null_logger.rb', line 17 def debug( = nil, &block) yield if block_given? && ENV["RUN_ALL_LOGGER_BLOCKS"] == "yes" end |
#error(message = nil) { ... } ⇒ nil
Logs an error message. Discards the message but may yield the block for testing.
44 45 46 |
# File 'lib/counting_semaphore/null_logger.rb', line 44 def error( = nil, &block) yield if block_given? && ENV["RUN_ALL_LOGGER_BLOCKS"] == "yes" end |
#fatal(message = nil) { ... } ⇒ nil
Logs a fatal message. Discards the message but may yield the block for testing.
53 54 55 |
# File 'lib/counting_semaphore/null_logger.rb', line 53 def fatal( = nil, &block) yield if block_given? && ENV["RUN_ALL_LOGGER_BLOCKS"] == "yes" end |
#info(message = nil) { ... } ⇒ nil
Logs an info message. Discards the message but may yield the block for testing.
26 27 28 |
# File 'lib/counting_semaphore/null_logger.rb', line 26 def info( = nil, &block) yield if block_given? && ENV["RUN_ALL_LOGGER_BLOCKS"] == "yes" end |
#warn(message = nil) { ... } ⇒ nil
Logs a warning message. Discards the message but may yield the block for testing.
35 36 37 |
# File 'lib/counting_semaphore/null_logger.rb', line 35 def warn( = nil, &block) yield if block_given? && ENV["RUN_ALL_LOGGER_BLOCKS"] == "yes" end |