Sha256: 067313f0ac0719e0682557c2e6046ddff0032213579f730ccc690ee111ecdfe6
Contents?: true
Size: 1.92 KB
Versions: 4
Compression:
Stored size: 1.92 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 :app_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:, app_name:) @app_name = app_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( app_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
4 entries across 4 versions & 1 rubygems