lib/log.rb in gridium-0.1.7 vs lib/log.rb in gridium-0.1.8
- old
+ new
@@ -1,7 +1,7 @@
# Logger class wraps around ruby 'logger' gem to provide diagnostic and workflow information
-
+require 'spec_data'
require 'logger'
# Add in multiple device logging directly into Logger class
class Logger
# Creates or opens a secondary log file.
@@ -42,101 +42,101 @@
end # class logger
# Singleton Logger class
module Gridium
-class Log
- # make this class static
- class << self
+ class Log
+ # make this class static
+ class << self
- #
- # more generic than INFO, useful for debugging issues
- # DEBUG = 0
- # generic, useful information about system operation
- # INFO = 1
- # a warning
- # WARN = 2
- # a handleable error condition
- # ERROR = 3
- # an unhandleable error that results in a program crash
- # FATAL = 4
- # an unknown message that should always be logged
- # UNKNOWN = 5
+ #
+ # more generic than INFO, useful for debugging issues
+ # DEBUG = 0
+ # generic, useful information about system operation
+ # INFO = 1
+ # a warning
+ # WARN = 2
+ # a handleable error condition
+ # ERROR = 3
+ # an unhandleable error that results in a program crash
+ # FATAL = 4
+ # an unknown message that should always be logged
+ # UNKNOWN = 5
- def debug(msg)
- log.debug(msg)
- end
+ def debug(msg)
+ log.debug(msg)
+ end
- def info(msg)
- log.info(msg)
- end
+ def info(msg)
+ log.info(msg)
+ end
- def warn(msg)
- log.warn(msg)
- Driver.save_screenshot('warning') if Gridium.config.screenshot_on_failure
- $execution_warnings << msg
- end
+ def warn(msg)
+ log.warn(msg)
+ Driver.save_screenshot('warning') if Gridium.config.screenshot_on_failure
+ SpecData.execution_warnings << msg
+ end
- def error(msg)
- log.error(msg)
- Driver.save_screenshot('error') if Gridium.config.screenshot_on_failure
- $verification_errors << msg
- end
+ def error(msg)
+ log.error(msg)
+ Driver.save_screenshot('error') if Gridium.config.screenshot_on_failure
+ SpecData.verification_errors << msg
+ end
- def add_device device
- @@devices ||= []
- log.attach(device)
- @@devices << device
- end
+ def add_device device
+ @@devices ||= []
+ log.attach(device)
+ @@devices << device
+ end
- def close
- @@devices.each { |dev| @@logger.detach(dev) }
- @@devices.clear
- log.close if log
- end
+ def close
+ @@devices.each { |dev| @@logger.detach(dev) }
+ @@devices.clear
+ log.close if log
+ end
- private
+ private
- def log
- @@logger ||= initialize_logger
- end
+ def log
+ @@logger ||= initialize_logger
+ end
- def initialize_logger
- # log to STDOUT and file
- logger ||= Logger.new(STDOUT)
+ def initialize_logger
+ # log to STDOUT and file
+ logger ||= Logger.new(STDOUT)
- # messages that have the set level or higher will be logged
- case Gridium.config.log_level
- when :debug then
- level = Logger::DEBUG
- when :info then
- level = Logger::INFO
- when :warn then
- level = Logger::WARN
- when :error then
- level = Logger::ERROR
- when :fatal then
- level = Logger::FATAL
- end
+ # messages that have the set level or higher will be logged
+ case Gridium.config.log_level
+ when :debug then
+ level = Logger::DEBUG
+ when :info then
+ level = Logger::INFO
+ when :warn then
+ level = Logger::WARN
+ when :error then
+ level = Logger::ERROR
+ when :fatal then
+ level = Logger::FATAL
+ end
- logger.level = level
+ logger.level = level
- logger.formatter = proc do |severity, datetime, progname, msg|
- base_msg = "[#{datetime.strftime('%Y-%m-%d %H:%M:%S')}][#{severity}]"
- sev = severity.to_s
- if sev.eql?("DEBUG")
- "#{base_msg} #{msg}\n"
- elsif sev.eql?("INFO")
- "#{base_msg} > #{msg}\n"
- elsif sev.eql?("WARN")
- "#{base_msg} X #{msg}\n"
- else
- "#{base_msg} X #{msg}\n"
+ logger.formatter = proc do |severity, datetime, progname, msg|
+ base_msg = "[#{datetime.strftime('%Y-%m-%d %H:%M:%S')}][#{severity}]"
+ sev = severity.to_s
+ if sev.eql?("DEBUG")
+ "#{base_msg} #{msg}\n"
+ elsif sev.eql?("INFO")
+ "#{base_msg} > #{msg}\n"
+ elsif sev.eql?("WARN")
+ "#{base_msg} X #{msg}\n"
+ else
+ "#{base_msg} X #{msg}\n"
+ end
end
- end
- logger
- end # initialize_logger
- end # class << self
-end # Log class
+ logger
+ end # initialize_logger
+ end # class << self
+ end # Log class
end
\ No newline at end of file