Improve logging

This commit is contained in:
Alex Kotov 2023-05-02 18:28:02 +04:00
parent 43565636e6
commit 2af3e40510
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08

View file

@ -65,10 +65,10 @@ module Diversipub
def webrick_options
@webrick_options ||= {
AccessLog: [],
AccessLog: webrick_access_log,
BindAddress: 'localhost',
DocumentRoot: nil,
Logger: Logger.new(File.open('/dev/null', 'w')),
Logger: web_logger,
Port: 8080,
}.freeze
end
@ -80,5 +80,17 @@ module Diversipub
def sinatra_app
@sinatra_app ||= SinatraApp.new self
end
def webrick_access_log
@webrick_access_log ||= [
[$stderr, WEBrick::AccessLog::COMMON_LOG_FORMAT],
].freeze
end
def web_logger
@web_logger ||= Logger.new(stderr).tap do |web_logger|
web_logger.level = Logger::INFO
end
end
end
end