Class: Console::Logger
- Inherits:
-
Object
- Object
- Console::Logger
- Defined in:
- lib/console/logger.rb
Overview
The standard logger interface with support for log levels and verbosity.
The log levels are: ‘debug`, `info`, `warn`, `error`, and `fatal`.
Constant Summary collapse
- DEFAULT_LEVEL =
1
Class Method Summary collapse
-
.default_log_level(env = ENV, verbose: $VERBOSE, debug: $DEBUG) ⇒ Object
Set the default log level based on ‘$DEBUG` and `$VERBOSE`.
Instance Method Summary collapse
-
#initialize(output, **options) ⇒ Logger
constructor
Create a new logger.
-
#progress(subject, total, **options) ⇒ Object
Create a progress indicator for the given subject.
Constructor Details
Class Method Details
.default_log_level(env = ENV, verbose: $VERBOSE, debug: $DEBUG) ⇒ Object
Set the default log level based on ‘$DEBUG` and `$VERBOSE`. You can also specify CONSOLE_LEVEL=debug or CONSOLE_LEVEL=info in environment. mislav.net/2011/06/ruby-verbose-mode/ has more details about how it all fits together.
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/console/logger.rb', line 29 def self.default_log_level(env = ENV, verbose: $VERBOSE, debug: $DEBUG) if level = env["CONSOLE_LEVEL"] LEVELS[level.to_sym] || level.to_i elsif debug DEBUG elsif verbose.nil? WARN else INFO end end |