Class: BackupRestore::Logger
- Inherits:
-
Object
- Object
- BackupRestore::Logger
- Defined in:
- lib/backup_restore/logger.rb
Instance Attribute Summary collapse
-
#logs ⇒ Object
readonly
Returns the value of attribute logs.
Instance Method Summary collapse
-
#initialize(user_id: nil, client_id: nil) ⇒ Logger
constructor
A new instance of Logger.
- #log(message, ex = nil) ⇒ Object
Constructor Details
#initialize(user_id: nil, client_id: nil) ⇒ Logger
Returns a new instance of Logger.
7 8 9 10 11 12 13 |
# File 'lib/backup_restore/logger.rb', line 7 def initialize(user_id: nil, client_id: nil) @user_id = user_id @client_id = client_id @publish_to_message_bus = @user_id.present? && @client_id.present? @logs = [] end |
Instance Attribute Details
#logs ⇒ Object (readonly)
Returns the value of attribute logs.
5 6 7 |
# File 'lib/backup_restore/logger.rb', line 5 def logs @logs end |
Instance Method Details
#log(message, ex = nil) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/backup_restore/logger.rb', line 15 def log(, ex = nil) return if Rails.env.test? = Time.now.strftime("%Y-%m-%d %H:%M:%S") puts() publish_log(, ) save_log(, ) if ex formatted_ex = "#{ex}\n" + ex.backtrace.join("\n") puts formatted_ex Rails.logger.error(formatted_ex) end end |