2021-05-01 23:02:08 +02:00
|
|
|
require "file_utils"
|
|
|
|
|
2021-12-12 18:01:55 +01:00
|
|
|
if LuckyEnv.test?
|
2021-05-01 23:02:08 +02:00
|
|
|
# Logs to `tmp/test.log`
|
|
|
|
FileUtils.mkdir_p("tmp")
|
|
|
|
|
|
|
|
backend = Log::IOBackend.new(File.new("tmp/test.log", mode: "w"))
|
|
|
|
backend.formatter = Lucky::PrettyLogFormatter.proc
|
|
|
|
Log.dexter.configure(:debug, backend)
|
2021-12-12 18:01:55 +01:00
|
|
|
elsif LuckyEnv.production?
|
2021-05-01 23:02:08 +02:00
|
|
|
backend = Log::IOBackend.new
|
|
|
|
backend.formatter = Dexter::JSONLogFormatter.proc
|
|
|
|
Log.dexter.configure(:info, backend)
|
|
|
|
else
|
|
|
|
backend = Log::IOBackend.new
|
|
|
|
backend.formatter = Lucky::PrettyLogFormatter.proc
|
|
|
|
Log.dexter.configure(:debug, backend)
|
|
|
|
DB::Log.level = :info
|
|
|
|
end
|
|
|
|
|
|
|
|
# If you want to log every pipe that runs, set the log level to ':info'
|
|
|
|
Lucky::ContinuedPipeLog.dexter.configure(:none)
|
|
|
|
|
|
|
|
# Set the log to ':info' to log all queries
|
|
|
|
Avram::QueryLog.dexter.configure(:none)
|
|
|
|
|
|
|
|
# Skip logging static assets requests in development
|
|
|
|
Lucky::LogHandler.configure do |settings|
|
2021-12-12 18:01:55 +01:00
|
|
|
if LuckyEnv.development?
|
2021-05-01 23:02:08 +02:00
|
|
|
settings.skip_if = ->(context : HTTP::Server::Context) {
|
|
|
|
context.request.method.downcase == "get" &&
|
|
|
|
context.request.resource.starts_with?(/\/css\/|\/js\/|\/assets\/|\/favicon\.ico/)
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|