Class: Kitchen::Logger
- Inherits:
-
Object
- Object
- Kitchen::Logger
- Includes:
- Logger::Severity
- Defined in:
- lib/kitchen/logger.rb
Overview
Logging implementation for Kitchen. By default the console/stdout output
will be displayed differently than the file log output. Therefor, this
class wraps multiple loggers that conform to the stdlib Logger
class
behavior.
Defined Under Namespace
Classes: LogdevLogger, StdoutLogger
Instance Attribute Summary collapse
-
#log_overwrite ⇒ Boolean
readonly
Whether logger is configured for overwriting.
-
#logdev ⇒ IO
readonly
The log device.
Instance Method Summary collapse
-
#:<<(: <<()) ⇒ Object
Dump one or more messages to info.
-
#add ⇒ Object
Log a message if the given severity is high enough.
-
#banner { ... } ⇒ nil, true
Log a message with severity of banner (high level).
-
#close ⇒ Object
Close the logging devices.
-
#datetime_format ⇒ String
The date format being used.
-
#datetime_format= ⇒ Object
Sets the date format being used.
-
#debug { ... } ⇒ nil, true
Log a message with severity of debug.
-
#debug? ⇒ true, false
Whether or not the current severity level allows for the printing of debug messages.
-
#error { ... } ⇒ nil, true
Log a message with severity of error.
-
#error? ⇒ true, false
Whether or not the current severity level allows for the printing of error messages.
-
#fatal { ... } ⇒ nil, true
Log a message with severity of fatal.
-
#fatal? ⇒ true, false
Whether or not the current severity level allows for the printing of fatal messages.
-
#info { ... } ⇒ nil, true
Log a message with severity of info.
-
#info? ⇒ true, false
Whether or not the current severity level allows for the printing of info messages.
-
#initialize(options = {}) ⇒ Logger
constructor
Constructs a new logger.
-
#level ⇒ Integer
The logging severity threshold.
-
#level= ⇒ Object
Sets the logging severity threshold.
-
#progname ⇒ String
Program name to include in log messages.
-
#progname= ⇒ Object
Sets the program name to include in log messages.
-
#unknown { ... } ⇒ nil, true
Log a message with severity of unknown.
-
#warn { ... } ⇒ nil, true
Log a message with severity of warn.
-
#warn? ⇒ true, false
Whether or not the current severity level allows for the printing of warn messages.
Constructor Details
#initialize(options = {}) ⇒ Logger
Constructs a new logger.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/kitchen/logger.rb', line 60 def initialize( = {}) @log_overwrite = if [:log_overwrite].nil? default_log_overwrite else [:log_overwrite] end @logdev = logdev_logger([:logdev], log_overwrite) if [:logdev] populate_loggers() # These setters cannot be called until @loggers are populated because # they are delegated self.progname = [:progname] || "Kitchen" self.level = [:level] || default_log_level end |
Instance Attribute Details
#log_overwrite ⇒ Boolean (readonly)
Returns whether logger is configured for overwriting.
39 40 41 |
# File 'lib/kitchen/logger.rb', line 39 def log_overwrite @log_overwrite end |
#logdev ⇒ IO (readonly)
Returns the log device.
35 36 37 |
# File 'lib/kitchen/logger.rb', line 35 def logdev @logdev end |
Instance Method Details
#:<<(: <<()) ⇒ Object
Dump one or more messages to info.
152 |
# File 'lib/kitchen/logger.rb', line 152 delegate_to_all_loggers :<< |
#add ⇒ Object
Log a message if the given severity is high enough.
146 |
# File 'lib/kitchen/logger.rb', line 146 delegate_to_all_loggers :add |
#banner { ... } ⇒ nil, true
Log a message with severity of banner (high level).
165 |
# File 'lib/kitchen/logger.rb', line 165 delegate_to_all_loggers :banner |
#close ⇒ Object
Close the logging devices.
273 |
# File 'lib/kitchen/logger.rb', line 273 delegate_to_all_loggers :close |
#datetime_format ⇒ String
Returns the date format being used.
135 |
# File 'lib/kitchen/logger.rb', line 135 delegate_to_first_logger :datetime_format |
#datetime_format= ⇒ Object
Sets the date format being used.
141 |
# File 'lib/kitchen/logger.rb', line 141 delegate_to_all_loggers :datetime_format= |
#debug { ... } ⇒ nil, true
Log a message with severity of debug.
178 |
# File 'lib/kitchen/logger.rb', line 178 delegate_to_all_loggers :debug |
#debug? ⇒ true, false
Returns whether or not the current severity level allows for the printing of debug messages.
183 |
# File 'lib/kitchen/logger.rb', line 183 delegate_to_first_logger :debug? |
#error { ... } ⇒ nil, true
Log a message with severity of error.
214 |
# File 'lib/kitchen/logger.rb', line 214 delegate_to_all_loggers :error |
#error? ⇒ true, false
Returns whether or not the current severity level allows for the printing of error messages.
219 |
# File 'lib/kitchen/logger.rb', line 219 delegate_to_first_logger :error? |
#fatal { ... } ⇒ nil, true
Log a message with severity of fatal.
250 |
# File 'lib/kitchen/logger.rb', line 250 delegate_to_all_loggers :fatal |
#fatal? ⇒ true, false
Returns whether or not the current severity level allows for the printing of fatal messages.
255 |
# File 'lib/kitchen/logger.rb', line 255 delegate_to_first_logger :fatal? |
#info { ... } ⇒ nil, true
Log a message with severity of info.
196 |
# File 'lib/kitchen/logger.rb', line 196 delegate_to_all_loggers :info |
#info? ⇒ true, false
Returns whether or not the current severity level allows for the printing of info messages.
201 |
# File 'lib/kitchen/logger.rb', line 201 delegate_to_first_logger :info? |
#level ⇒ Integer
Returns the logging severity threshold.
115 |
# File 'lib/kitchen/logger.rb', line 115 delegate_to_first_logger :level |
#level= ⇒ Object
Sets the logging severity threshold.
121 |
# File 'lib/kitchen/logger.rb', line 121 delegate_to_all_loggers :level= |
#progname ⇒ String
Returns program name to include in log messages.
125 |
# File 'lib/kitchen/logger.rb', line 125 delegate_to_first_logger :progname |
#progname= ⇒ Object
Sets the program name to include in log messages.
131 |
# File 'lib/kitchen/logger.rb', line 131 delegate_to_all_loggers :progname= |
#unknown { ... } ⇒ nil, true
Log a message with severity of unknown.
268 |
# File 'lib/kitchen/logger.rb', line 268 delegate_to_all_loggers :unknown |
#warn { ... } ⇒ nil, true
Log a message with severity of warn.
232 |
# File 'lib/kitchen/logger.rb', line 232 delegate_to_all_loggers :warn |
#warn? ⇒ true, false
Returns whether or not the current severity level allows for the printing of warn messages.
237 |
# File 'lib/kitchen/logger.rb', line 237 delegate_to_first_logger :warn? |