Module: Vines::Log

Constant Summary collapse

@@logger =
nil

Instance Method Summary collapse

Instance Method Details

#logObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/vines/log.rb', line 6

def log
  unless @@logger
    @@logger = Logger.new(STDOUT)
    @@logger.level = Logger::INFO
    @@logger.progname = 'vines'
    @@logger.formatter = Class.new(Logger::Formatter) do
      def initialize
        @time = "%Y-%m-%d %H:%M:%S".freeze
        @fmt  = "[%s] %5s -- %s: %s\n".freeze
      end
      def call(severity, time, program, msg)
        @fmt % [time.utc.strftime(@time), severity, program, msg2str(msg)]
      end
    end.new
  end
  @@logger
end