Module: CommandLineBoss::LoggerOptions
- Defined in:
- lib/command_line_boss/logger_options.rb
Overview
Add –debug and –verbose options and a logger method
Instance Attribute Summary collapse
-
#debug ⇒ Boolean
readonly
private
true if the –debug option was given.
-
#verbose ⇒ Boolean
readonly
private
true if the –verbose option was given.
Instance Method Summary collapse
-
#logger ⇒ Logger
The logger to use to report progress.
Instance Attribute Details
#debug ⇒ Boolean (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
true if the –debug option was given
12 13 14 |
# File 'lib/command_line_boss/logger_options.rb', line 12 def debug @debug end |
#verbose ⇒ Boolean (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
true if the –verbose option was given
20 21 22 |
# File 'lib/command_line_boss/logger_options.rb', line 20 def verbose @verbose end |
Instance Method Details
#logger ⇒ Logger
The logger to use to report progress
Messages are logged at info and debug levels. The logger returned is one of the following:
-
A logger that logs to the console at the :info level if verbose mode is enabled
-
A logger that logs to the console at the :debug level if debug mode is enabled
-
Otherwise a null logger that does not log anything
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/command_line_boss/logger_options.rb', line 36 def logger @logger ||= if verbose verbose_logger elsif debug debug_logger else Logger.new(nil, level: Logger::UNKNOWN + 1) end end |