Sha256: 57ba272a71a645cdac3041bd3af807d2cf0c0abcd2c47f8a3c3ba193fc0d24fb

Contents?: true

Size: 696 Bytes

Versions: 6

Compression:

Stored size: 696 Bytes

Contents

# frozen_string_literal: true

require 'logger'

module Riserva
  class Log
    attr_reader :logger

    def initialize
      @logger = Logger.new(
        Riserva::Config.read('log.filename') || STDOUT,
        Riserva::Config.read('log.files_to_keep') || 1,
        Riserva::Config.read('log.size') || 100 * 1024
      )

      @logger.datetime_format = datetime_format
      @logger.formatter = formatter
    end

    private

    def formatter
      proc do |severity, datetime, progname, msg|
        "[#{datetime}] #{severity} -- #{progname}: #{msg}\n"
      end
    end

    def datetime_format
      Riserva::Config.read('log.datetime_format') || '%Y-%m-%d %H:%M:%S %Z'
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
riserva-0.1.7 lib/riserva/log.rb
riserva-0.1.6 lib/riserva/log.rb
riserva-0.1.5 lib/riserva/log.rb
riserva-0.1.4 lib/riserva/log.rb
riserva-0.1.3 lib/riserva/log.rb
riserva-0.1.2 lib/riserva/log.rb