Class: Roast::Helpers::Logger
- Inherits:
-
Object
- Object
- Roast::Helpers::Logger
- Extended by:
- Forwardable
- Defined in:
- lib/roast/helpers/logger.rb
Overview
Central logger for the Roast application
Constant Summary collapse
- VALID_LOG_LEVELS =
["DEBUG", "INFO", "WARN", "ERROR", "FATAL"].freeze
Instance Attribute Summary collapse
-
#log_level ⇒ Object
Returns the value of attribute log_level.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Class Method Summary collapse
- .instance ⇒ Object
-
.reset ⇒ Object
For testing purposes.
Instance Method Summary collapse
-
#debug(message) ⇒ Object
Create a specialized debug method that ensures proper functionality.
- #error(message) ⇒ Object
- #fatal(message) ⇒ Object
-
#initialize(stdout: $stdout, log_level: ENV["ROAST_LOG_LEVEL"] || "INFO") ⇒ Logger
constructor
A new instance of Logger.
Constructor Details
#initialize(stdout: $stdout, log_level: ENV["ROAST_LOG_LEVEL"] || "INFO") ⇒ Logger
Returns a new instance of Logger.
33 34 35 36 |
# File 'lib/roast/helpers/logger.rb', line 33 def initialize(stdout: $stdout, log_level: ENV["ROAST_LOG_LEVEL"] || "INFO") @log_level = validate_log_level(log_level) @logger = create_logger(stdout) end |
Instance Attribute Details
#log_level ⇒ Object
Returns the value of attribute log_level.
13 14 15 |
# File 'lib/roast/helpers/logger.rb', line 13 def log_level @log_level end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
13 14 15 |
# File 'lib/roast/helpers/logger.rb', line 13 def logger @logger end |
Class Method Details
.instance ⇒ Object
46 47 48 |
# File 'lib/roast/helpers/logger.rb', line 46 def instance @instance ||= new end |
.reset ⇒ Object
For testing purposes
54 55 56 |
# File 'lib/roast/helpers/logger.rb', line 54 def reset @instance = nil end |
Instance Method Details
#debug(message) ⇒ Object
Create a specialized debug method that ensures proper functionality
19 20 21 |
# File 'lib/roast/helpers/logger.rb', line 19 def debug() logger.debug() end |
#error(message) ⇒ Object
23 24 25 26 |
# File 'lib/roast/helpers/logger.rb', line 23 def error() # Add any custom error handling logic here logger.error() end |
#fatal(message) ⇒ Object
28 29 30 31 |
# File 'lib/roast/helpers/logger.rb', line 28 def fatal() # Add any custom fatal error handling logic here logger.fatal() end |