module Utils::LocalLogger
Public Instance Methods
all_logger()
click to toggle source
Class wide console and file logger. Message appears on console output and it's stored on file
# File lib/crtu/utils/logger.rb, line 126 def all_logger log_file = (LOCAL_LOGGER_LOG_FILE.nil?) ? File.join(Dir.tmpdir , "#{self.class}.log") : LOCAL_LOGGER_LOG_FILE @logger = Log4r::Logger.new('LocalLoggerConsoleAndFile') pf = PatternFormatter.new(:pattern => "[%l] : #{self.class} @ %d : %M") so = StdoutOutputter.new('console', :formatter => pf) fo = RollingFileOutputter.new('f1', filename: log_file, trunc: false, formatter: pf, maxtime: SECONDS_IN_DAY) @logger.outputters << so @logger.outputters << fo @logger.level = DEBUG @logger end
console_logger()
click to toggle source
Class console logger. The messages only go to the stdout No message is saved to file
# File lib/crtu/utils/logger.rb, line 97 def console_logger @logger = Log4r::Logger.new('LocalLoggerConsole') pf = PatternFormatter.new(:pattern => "[%l] : #{self.class} @ %d : %M") so = StdoutOutputter.new('console', :formatter => pf) @logger.outputters << so @logger.level = DEBUG @logger end
file_logger()
click to toggle source
Class simple file logger. Message is stored in file, but it does not appear on stdout
# File lib/crtu/utils/logger.rb, line 109 def file_logger log_file = (LOCAL_LOGGER_LOG_FILE.nil?) ? File.join(Dir.tmpdir , "#{self.class}.log") : LOCAL_LOGGER_LOG_FILE @logger = Log4r::Logger.new('LocalLoggerFile') pf = PatternFormatter.new(:pattern => "[%l] : #{self.class} @ %d : %M") fo = RollingFileOutputter.new('f1', filename: log_file, trunc: false, formatter: pf, maxtime: SECONDS_IN_DAY) @logger.outputters << fo @logger.level = DEBUG @logger end