Class: LoggingClass
- Inherits:
-
Object
- Object
- LoggingClass
- Defined in:
- lib/miq_utilities/logging.rb
Overview
Wrapper class for logging
Instance Method Summary collapse
-
#initialize(name) ⇒ LoggingClass
constructor
initialize class.
- #log(level:, message:, logtoscreenonly: false, notify: false, email_to: nil, email_from: nil, signature: nil, webhookurl: nil, subjecttype: nil, update_message: false) ⇒ Object
Constructor Details
#initialize(name) ⇒ LoggingClass
initialize class
22 23 24 25 |
# File 'lib/miq_utilities/logging.rb', line 22 def initialize(name) @initializer = name @notification = NotificationClass.new end |
Instance Method Details
#log(level:, message:, logtoscreenonly: false, notify: false, email_to: nil, email_from: nil, signature: nil, webhookurl: nil, subjecttype: nil, update_message: false) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/miq_utilities/logging.rb', line 27 def log(level:, message:, logtoscreenonly: false, notify: false, email_to: nil, email_from: nil, signature: nil, webhookurl: nil, subjecttype: nil, update_message: false) levelvalid = %w[info warn error debug].any? { |msglevel| level.upcase.include? msglevel.to_s.upcase } if $evm.nil? || logtoscreenonly puts "#{level}: #{@initializer} - #{}" elsif levelvalid $evm.log(level, "#{@initializer} - #{}") @task. = if @task && (level.casecmp('ERROR').zero? || ) else $evm.log('info', "#{@initializer} - #{}") end # Notify - Only if flag (notify) is set to TRUE @notification.notify(event_level: level, event_message: , email_to: email_to, email_from: email_from, signature: signature, webhookurl: webhookurl, subjecttype: subjecttype) if notify rescue => err raise("Oopps! Something went wrong.\nDetails:<#{err}>") end |