-
-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable clogger again, with an option to only send to a file.
- Loading branch information
1 parent
092e2d9
commit ad99a8c
Showing
5 changed files
with
23 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,22 @@ | ||
# frozen_string_literal: true | ||
|
||
# disable Sinatra's logger | ||
if defined?(Clogger) || ENV["DISABLE_ACCESS_LOG"] | ||
if ENV.has_key?("CLOGGER") | ||
# disable Sinatra's logger | ||
disable :logging | ||
end | ||
|
||
# https://bogomips.org/clogger/ | ||
# this format 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) | ||
if defined?(Clogger) && !ENV["DISABLE_ACCESS_LOG"] | ||
use Clogger, logger: $stdout, reentrant: true, format: '~ $ip "$request" $status $response_length "$http_referer"' | ||
# https://yhbt.net/clogger/ | ||
# this format is similar to "Combined", but without $time_local and $http_user_agent (and using $ip instead of $remote_addr) | ||
# Combined: $remote_addr - $remote_user [$time_local] $request" $status $response_length "$http_referer" "$http_user_agent" | ||
# 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) | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters