Module: LigaMagicScraper::Loggable
- Included in:
- AlertSystem, Alerts::FileAlert, Alerts::TelegramAlert, BaseScraper
- Defined in:
- lib/ligamagic_scraper/loggable.rb
Instance Attribute Summary collapse
-
#logs ⇒ Object
readonly
Returns the value of attribute logs.
Instance Method Summary collapse
- #clear_logs ⇒ Object
- #formatted_logs ⇒ Object
- #initialize_logs ⇒ Object
- #log(message, level: :info) ⇒ Object
- #log_debug(message) ⇒ Object
- #log_error(message) ⇒ Object
- #log_info(message) ⇒ Object
- #log_warning(message) ⇒ Object
Instance Attribute Details
#logs ⇒ Object (readonly)
Returns the value of attribute logs.
3 4 5 |
# File 'lib/ligamagic_scraper/loggable.rb', line 3 def logs @logs end |
Instance Method Details
#clear_logs ⇒ Object
38 39 40 |
# File 'lib/ligamagic_scraper/loggable.rb', line 38 def clear_logs @logs = [] end |
#formatted_logs ⇒ Object
34 35 36 |
# File 'lib/ligamagic_scraper/loggable.rb', line 34 def formatted_logs @logs.map { |entry| entry[:message] } end |
#initialize_logs ⇒ Object
5 6 7 |
# File 'lib/ligamagic_scraper/loggable.rb', line 5 def initialize_logs @logs = [] end |
#log(message, level: :info) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/ligamagic_scraper/loggable.rb', line 9 def log(, level: :info) @logs << { timestamp: Time.now, level: level, message: , source: self.class.name } end |
#log_debug(message) ⇒ Object
22 23 24 |
# File 'lib/ligamagic_scraper/loggable.rb', line 22 def log_debug() log(, level: :debug) end |
#log_error(message) ⇒ Object
30 31 32 |
# File 'lib/ligamagic_scraper/loggable.rb', line 30 def log_error() log(, level: :error) end |
#log_info(message) ⇒ Object
18 19 20 |
# File 'lib/ligamagic_scraper/loggable.rb', line 18 def log_info() log(, level: :info) end |
#log_warning(message) ⇒ Object
26 27 28 |
# File 'lib/ligamagic_scraper/loggable.rb', line 26 def log_warning() log(, level: :warning) end |