Class: TxCatcher::Logger
- Inherits:
-
Object
- Object
- TxCatcher::Logger
- Defined in:
- lib/txcatcher/logger.rb
Constant Summary collapse
- LOG_LEVELS =
{ info: 1, warn: 2, error: 3, fatal: 4, unknown: 5 }
Instance Attribute Summary collapse
-
#reporters ⇒ Object
Returns the value of attribute reporters.
Instance Method Summary collapse
-
#initialize(log_file: "txcatcher.log", error_file: "error.log", error_log_delimiter: "\n\n", reporters: [:logfile, :stdout, :sentry]) ⇒ Logger
constructor
A new instance of Logger.
- #report(message, log_level = :info, data: nil, timestamp: false, newline: "\n") ⇒ Object
Constructor Details
#initialize(log_file: "txcatcher.log", error_file: "error.log", error_log_delimiter: "\n\n", reporters: [:logfile, :stdout, :sentry]) ⇒ Logger
Returns a new instance of Logger.
15 16 17 18 19 20 |
# File 'lib/txcatcher/logger.rb', line 15 def initialize(log_file: "txcatcher.log", error_file: "error.log", error_log_delimiter: "\n\n", reporters: [:logfile, :stdout, :sentry]) @log_file_name = log_file @error_log_file_name = error_file @error_log_delimiter = error_log_delimiter @reporters = reporters end |
Instance Attribute Details
#reporters ⇒ Object
Returns the value of attribute reporters.
13 14 15 |
# File 'lib/txcatcher/logger.rb', line 13 def reporters @reporters end |
Instance Method Details
#report(message, log_level = :info, data: nil, timestamp: false, newline: "\n") ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/txcatcher/logger.rb', line 23 def report(, log_level=:info, data: nil, timestamp: false, newline: "\n") @reporters.each do |out| if LOG_LEVELS[log_level] >= LOG_LEVELS[Config["logger"]["#{out}_level"].to_sym] send("report_to_#{out}", , log_level, data: data, timestamp: , newline: newline) end end end |