module AutomationHelpers
{AutomationHelpers} namespace
Constants
- VERSION
Attributes
Public Class Methods
# File lib/automation_helpers.rb, line 14 def configure yield self end
To query what level is being logged
AutomationHelpers.log_level => :INFO # By default
# File lib/automation_helpers.rb, line 64 def log_level %i[DEBUG INFO WARN ERROR FATAL UNKNOWN][logger.level] end
To enable full logging (This uses the Ruby API, so can accept any of a Symbol / String
/ Integer as an input
AutomationHelpers.log_level = :DEBUG AutomationHelpers.log_level = 'DEBUG' AutomationHelpers.log_level = 0
To disable all logging
AutomationHelpers.log_level = :UNKNOWN
# File lib/automation_helpers.rb, line 57 def log_level=(value) logger.level = value end
This writer method allows you to configure where you want the output of the automation_helpers logs to go (Default is $stdout)
example: AutomationHelpers.log_path = ‘automation_helpers.log’ would save all log messages to ‘./automation_helpers.log`
# File lib/automation_helpers.rb, line 45 def log_path=(logdev) logger.reopen(logdev) end
The Automation Helpers logger object - This is called automatically in several locations and will log messages according to the normal Ruby protocol To alter (or check), the log level; call .log_level= or .log_level
This logger object can also be used to manually log messages
To Manually log a message
AutomationHelpers.logger.info('Information') AutomationHelpers.logger.debug('Input debug message')
By default the logger will output all messages to $stdout, but can be altered to log to a file or another IO location by calling ‘.log_path=`
# File lib/automation_helpers.rb, line 30 def logger @logger ||= Logger.create end
# File lib/automation_helpers.rb, line 34 def logger=(logger) raise ArgumentError, 'You must supply an existing Logger' unless logger.is_a?(::Logger) @logger = logger end