Sha256: 9b9eac0a38f20ecd6026c00432b3b638fe7e520c079cda3cfdc2b27cf2cbf498

Contents?: true

Size: 552 Bytes

Versions: 1

Compression:

Stored size: 552 Bytes

Contents

require 'logger'
require 'thron/config'

module Thron
  extend self

  LOGGER_FILE   = Thron::root.join('log', 'thron.log')
  LOGGER_LEVELS = %i[debug info warn error fatal unknown]

  def logger_level
    LOGGER_LEVELS.fetch(logger.level)
  end

  def logger(options = {})
    file = options.fetch(:file) { LOGGER_FILE }
    level = options.fetch(:level) { Config::logger::level }
    @logger ||= Logger.new(file).tap do |logger|
      logger.level = level
    end
  end

  def reset_logger(logger = Logger.new(STDOUT))
    @logger = logger
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
thron-0.7.0 lib/thron/logger.rb