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 Method Summary collapse
-
#initialize(log_file: "txcatcher.log", error_file: "error.log", error_log_delimiter: "\n\n") ⇒ Logger
constructor
A new instance of Logger.
- #report(message, log_level = :info, data: nil, timestamp: false) ⇒ Object
Constructor Details
#initialize(log_file: "txcatcher.log", error_file: "error.log", error_log_delimiter: "\n\n") ⇒ Logger
Returns a new instance of Logger.
13 14 15 16 17 |
# File 'lib/txcatcher/logger.rb', line 13 def initialize(log_file: "txcatcher.log", error_file: "error.log", error_log_delimiter: "\n\n") @log_file_name = log_file @error_log_file_name = error_file @error_log_delimiter = error_log_delimiter end |
Instance Method Details
#report(message, log_level = :info, data: nil, timestamp: false) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/txcatcher/logger.rb', line 20 def report(, log_level=:info, data: nil, timestamp: false) [:logfile, :stdout, :sentry].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: ) end end end |