Sha256: 5060f0d157a7d423757440cefeaea394dfaef59806f983a5b1d7ddf6aafb0c52
Contents?: true
Size: 1.9 KB
Versions: 1
Compression:
Stored size: 1.9 KB
Contents
# frozen_string_literal: true require "dry/configurable" require "hanami/logger" module Hanami class Config # Hanami logger config # # @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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hanami-2.0.0.beta4 | lib/hanami/config/logger.rb |