Sha256: 3d0a8bfd5340e743cd487c8c888fb9952ad170f5a218f6f07fb97a652986b3d1
Contents?: true
Size: 903 Bytes
Versions: 1
Compression:
Stored size: 903 Bytes
Contents
require 'singleton' require 'logger' module RestFtpDaemon class LoggerPool include Singleton def initialize @loggers = {} end def get pipe @loggers[pipe] ||= create(pipe) end def create pipe # Compute file path / STDERR logfile = Settings.logs[pipe] if Settings.logs.is_a? Hash logfile ||= STDERR #logfile ||= STDOUT # Create the logger and return it logger = Logger.new(logfile, 'daily') #, 10, 1024000) logger.progname = pipe.to_s.upcase logger.formatter = proc do |severity, datetime, progname, message| # stamp = Time.now.strftime("%Y-%m-%d %H:%M:%S") stamp = datetime.strftime("%Y-%m-%d %H:%M:%S") field_pipe = "%-#{DEFAULT_LOGS_PIPE_LEN.to_i}s" % progname "#{stamp} #{field_pipe} #{message}\n" end # Finally return this logger logger end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rest-ftp-daemon-0.100.2 | lib/rest-ftp-daemon/logger_pool.rb |