Sha256: 2e3c31bd9e09d16986327a014f0c87599886a3eac5c52d6e8a8139b8f05f2190
Contents?: true
Size: 1.05 KB
Versions: 1
Compression:
Stored size: 1.05 KB
Contents
require 'logger' module Filum class Logger < ::Logger attr_reader :logfile def initialize(logfile, options = {}) @timings = {} @logfile = logfile create_log_directory super(logfile, shift_age='daily') self.formatter = Filum::LogFormatter.new(options) self.level = Logger::INFO end def context_id=(context_id) Thread.current[:context_id] = context_id end def start_timing(label) @timings[label] = Time.now info("Started timing for #{label} at #{@timings[label]}") end def end_timing(label) finish = Time.now if @timings[label] info("Stopped timing for #{label} at #{@timings[label]}, #{(finish.to_f - @timings[label].to_f).round(3)}") else info("Stopped timing for #{label} at #{@timings[label]}, no start time found") end end private def create_log_directory return unless @logfile.is_a?(String) dir = File.dirname(@logfile) unless File.directory?(dir) FileUtils.mkdir_p(dir) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
filum-2.2.0 | lib/filum/logger.rb |