mirror of
https://gitea.invidious.io/iv-org/shard-kemal.git
synced 2024-08-15 00:53:36 +00:00
Move logger to config
This commit is contained in:
parent
2af3648682
commit
51092fbb91
2 changed files with 13 additions and 6 deletions
10
src/kemal.cr
10
src/kemal.cr
|
@ -6,12 +6,8 @@ at_exit do
|
|||
config = Kemal.config
|
||||
if config.logging
|
||||
logger = Kemal::Logger.new
|
||||
config.add_handler logger
|
||||
logger.write "[#{config.env}] Kemal is ready to lead at #{config.scheme}://#{config.host_binding}:#{config.port}\n"
|
||||
Signal::INT.trap {
|
||||
logger.write "Kemal is going to take a rest!\n"
|
||||
logger.handler.close
|
||||
}
|
||||
config.logger = logger
|
||||
config.logger.write "[#{config.env}] Kemal is ready to lead at #{config.scheme}://#{config.host_binding}:#{config.port}\n"
|
||||
end
|
||||
config.add_handler Kemal::StaticFileHandler.new(config.public_folder)
|
||||
config.add_handler Kemal::Handler::INSTANCE
|
||||
|
@ -20,6 +16,8 @@ at_exit do
|
|||
server.ssl = config.ssl
|
||||
|
||||
Signal::INT.trap {
|
||||
config.logger.write "Kemal is going to take a rest!\n"
|
||||
config.logger.handler.close
|
||||
server.close
|
||||
exit
|
||||
}
|
||||
|
|
|
@ -22,6 +22,15 @@ module Kemal
|
|||
HANDLERS
|
||||
end
|
||||
|
||||
def logger
|
||||
@logger
|
||||
end
|
||||
|
||||
def logger=(logger)
|
||||
HANDLERS << logger
|
||||
@logger = logger
|
||||
end
|
||||
|
||||
def add_handler(handler : HTTP::Handler)
|
||||
HANDLERS << handler
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue