Sha256: 9692ec3e674cdc69f6a26636cdf11c0a58c087dab86b40932f893d538a2f0e72
Contents?: true
Size: 1.12 KB
Versions: 17
Compression:
Stored size: 1.12 KB
Contents
require "logger" module RestFtpDaemon # Logger interface class to access logger though symbolic names 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 # Create the logger and return it logger = Logger.new(logfile, LOG_ROTATION) #, 10, 1024000) logger.progname = pipe.to_s.upcase # And the formatter logger.formatter = proc do |severity, datetime, progname, messages| # Build common line prefix prefix = LOG_FORMAT_PREFIX % [ datetime.strftime(LOG_FORMAT_TIME), severity, progname, ] # If we have a bunch of lines, prefix them and send them together if messages.is_a? Array messages.map { |line| prefix + line + LOG_NEWLINE}.join else prefix + messages.to_s + LOG_NEWLINE end end # Finally return this logger logger end end end
Version data entries
17 entries across 17 versions & 1 rubygems