class BatchManager::Logger
Attributes
log_file[R]
logger[RW]
Public Class Methods
log_file_path(batch_name, is_wet = false)
click to toggle source
# File lib/batch_manager/logger.rb, line 10 def log_file_path(batch_name, is_wet = false) log_file_name = is_wet ? "#{batch_name}_wet" : batch_name File.join(BatchManager.log_dir, log_file_name) + ".log" end
new(batch_name, is_wet, disable_stdout = false)
click to toggle source
# File lib/batch_manager/logger.rb, line 16 def initialize(batch_name, is_wet, disable_stdout = false) @logger = Log4r::Logger.new(batch_name) @logger.outputters << Log4r::Outputter.stdout unless disable_stdout if BatchManager.save_log? @log_file = prepare_log_file(batch_name, is_wet) @logger.outputters << Log4r::FileOutputter.new(File.basename(@log_file, ".log"), :filename => @log_file) end BatchManager.logger = self end
Public Instance Methods
close()
click to toggle source
# File lib/batch_manager/logger.rb, line 36 def close BatchManager.logger = nil end
prepare_log_file(batch_name, is_wet)
click to toggle source
# File lib/batch_manager/logger.rb, line 26 def prepare_log_file(batch_name, is_wet) file_path = self.class.log_file_path(batch_name, is_wet) unless File.exist?(file_path) FileUtils.mkdir_p(File.dirname(file_path), :mode => 0775) FileUtils.touch(file_path) FileUtils.chmod(0664, file_path) end file_path end