Class: Hanami::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/hanami/ruby3/hanami/configuration.rb,
lib/hanami/ruby3/hanami/configuration/middleware.rb

Defined Under Namespace

Classes: Middleware

Instance Method Summary collapse

Instance Method Details

#logger(*args, **kwargs) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/hanami/ruby3/hanami/configuration.rb', line 4

def logger(*args, **kwargs)
  if args.empty? && kwargs.empty?
    settings.fetch(:logger, nil)
  # NOTE: Custom logger definition support, like:
  # environment :test do
  #   logger Logger.new(level: :fatal)
  elsif kwargs.empty?
    settings[:logger] = [*args]
  # NOTE: Hash-based logger definition support, like:
  # environment :test do
  #   logger level: :fatal
  else
    settings[:logger] = [*args, kwargs]
  end
end