Fix multiple logger handlers when custom logger is used (#653)

This commit is contained in:
Aravinda Vishwanathapura 2023-02-17 10:43:54 +05:30 committed by GitHub
parent ae7cda8291
commit 19661893ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -48,13 +48,13 @@ end
# This is used to replace the built-in `Kemal::LogHandler` with a custom logger. # This is used to replace the built-in `Kemal::LogHandler` with a custom logger.
# #
# A custom logger must inherit from `Kemal::BaseLogHandler` and must implement # A custom logger must inherit from `Kemal::BaseLogHandler` and must implement
# `call(env)`, `write(message)` methods. # `call(context)`, `write(message)` methods.
# #
# ``` # ```
# class MyCustomLogger < Kemal::BaseLogHandler # class MyCustomLogger < Kemal::BaseLogHandler
# def call(env) # def call(context)
# puts "I'm logging some custom stuff here." # puts "I'm logging some custom stuff here."
# call_next(env) # => This calls the next handler # call_next(context) # => This calls the next handler
# end # end
# #
# # This is used from `log` method. # # This is used from `log` method.
@ -71,7 +71,6 @@ end
# ``` # ```
def logger(logger : Kemal::BaseLogHandler) def logger(logger : Kemal::BaseLogHandler)
Kemal.config.logger = logger Kemal.config.logger = logger
Kemal.config.add_handler logger
end end
# Enables / Disables static file serving. # Enables / Disables static file serving.