Skip to content

Commit

Permalink
Work around Clogger outputting two log lines for compressed requests …
Browse files Browse the repository at this point in the history
…by putting it before Rack::Deflater in the list of middlewares. I was not able to figure out why it happened.
  • Loading branch information
stefansundin committed Feb 4, 2021
1 parent 69cbea0 commit 82f69c8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 22 deletions.
18 changes: 18 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,24 @@
# set :environment, :production

configure do
# https://yhbt.net/clogger/
# The default format below is similar to "Combined", but without $time_local and $http_user_agent (and using $ip instead of $remote_addr). Removing time and user-agent saves ~50% on log filesize.
# The purpose of ~ is to allow for easier grepping with -E '^~' (i.e. filtering out exceptions and other crap)
# Combined: $remote_addr - $remote_user [$time_local] $request" $status $response_length "$http_referer" "$http_user_agent"
if ENV.has_key?("CLOGGER")
disable :logging # Disable Sinatra's logger
opts = {
reentrant: true,
format: ENV["CLOGGER_FORMAT"] || '~ $ip "$request" $status $response_length "$http_referer"',
}
if ENV.has_key?("CLOGGER_FILE")
opts[:path] = ENV["CLOGGER_FILE"]
else
opts[:logger] = $stdout
end
use Clogger, opts
end

use Rack::Deflater, sync: false
use Rack::SslEnforcer, only_hosts: (ENV["SSL_ENFORCER_HOST"] || /\.herokuapp\.com$/)
use SecureHeaders::Middleware
Expand Down
22 changes: 0 additions & 22 deletions config/initializers/05-logging.rb

This file was deleted.

0 comments on commit 82f69c8

Please sign in to comment.