class BatchKit::Logging::Log4rFacade

Public Class Methods

new(logger) click to toggle source
# File lib/batch-kit/logging/log4r_logger.rb, line 14
def initialize(logger)
    @log4r_logger = logger
end

Public Instance Methods

level() click to toggle source
# File lib/batch-kit/logging/log4r_logger.rb, line 19
def level
    Log4r::LNAMES[@log4r_logger.level].downcase.intern
end
level=(lvl) click to toggle source
# File lib/batch-kit/logging/log4r_logger.rb, line 24
def level=(lvl)
    @log4r_logger.level = Log4r::LNAMES.index(lvl.to_s.upcase)
end
log_file() click to toggle source
# File lib/batch-kit/logging/log4r_logger.rb, line 29
def log_file
    out_name = "#{self.name}_file"
    fo = @log4r_logger.outputters.find{ |o| o.name == out_name }
    fo && fo.filename
end
log_file=(log_path) click to toggle source
# File lib/batch-kit/logging/log4r_logger.rb, line 36
def log_file=(log_path)
    out_name = "#{self.name}_file"
    if outputter = Log4r::Outputter[out_name]
        outputter.close
        @log4r_logger.remove out_name
    end
    if log_path
        FileUtils.mkdir_p(File.dirname(log_path))
        formatter = Log4r::PatternFormatter.new(pattern: '[%d] %-6l %x %M\r')
        outputter = Log4r::FileOutputter.new(out_name, filename: log_path,
                                             trunc: false, formatter: formatter)
        @log4r_logger.add out_name
    end
end
method_missing(mthd, *args) click to toggle source
# File lib/batch-kit/logging/log4r_logger.rb, line 63
def method_missing(mthd, *args)
    @log4r_logger.send(mthd, *args)
end