Sha256: b6df14734591cf512dc50b1379f6b9159e7b84212654e4c23e274093b2f72e83
Contents?: true
Size: 1.96 KB
Versions: 1
Compression:
Stored size: 1.96 KB
Contents
# frozen_string_literal: true require "dry/configurable" require "hanami/logger" module Hanami class Configuration # Hanami logger configuration # # @since 2.0.0 class Logger include Dry::Configurable attr_reader :application_name protected :config setting :level setting :stream setting :formatter setting :colors setting :filters, default: %w[_csrf password password_confirmation].freeze setting :options, default: [], constructor: ->(value) { Array(value).flatten }, cloneable: true setting :logger_class, default: Hanami::Logger def initialize(env:, application_name:) @application_name = application_name config.level = case env when :production :info else :debug end config.stream = case env when :test File.join("log", "#{env}.log") else $stdout end config.formatter = case env when :production :json end config.colors = case env when :production, :test false end end def instance logger_class.new( application_name.name, *options, stream: stream, level: level, formatter: formatter, filter: filters, colorizer: colors ) end private def method_missing(name, *args, &block) if config.respond_to?(name) config.public_send(name, *args, &block) else super end end def respond_to_missing?(name, _incude_all = false) config.respond_to?(name) || super end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hanami-2.0.0.alpha8 | lib/hanami/configuration/logger.rb |