Sha256: 4fb4c51b62d023ae6ede2c6e6945fcf323728b83b046286099a76cd54ffaad7b

Contents?: true

Size: 572 Bytes

Versions: 1

Compression:

Stored size: 572 Bytes

Contents

require 'logger'

module Filum
  class Logger < ::Logger

    attr_reader :logfile
    def initialize(logfile, options = {})
      @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

    private
    def create_log_directory
      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.0.0 lib/filum/logger.rb