Module: Vines::Log

Constant Summary collapse

@@logger =
nil

Instance Method Summary collapse

Instance Method Details

#logObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/vines.rb', line 38

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-%dT%H:%M:%SZ".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