Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused constants from Puma::CommonLogger. #1079

Merged
merged 3 commits into from Sep 8, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 11 additions & 17 deletions lib/puma/commonlogger.rb
Expand Up @@ -21,6 +21,13 @@ class CommonLogger
# %{%s - %s [%s] "%s %s%s %s" %d %s\n} %
FORMAT = %{%s - %s [%s] "%s %s%s %s" %d %s %0.4f\n}

HIJACK_FORMAT = %{%s - %s [%s] "%s %s%s %s" HIJACKED -1 %0.4f\n}

CONTENT_LENGTH = 'Content-Length'.freeze
PATH_INFO = 'PATH_INFO'.freeze
QUERY_STRING = 'QUERY_STRING'.freeze
REQUEST_METHOD = 'REQUEST_METHOD'.freeze

def initialize(app, logger=nil)
@app = app
@logger = logger
Expand All @@ -42,8 +49,6 @@ def call(env)
[status, header, body]
end

HIJACK_FORMAT = %{%s - %s [%s] "%s %s%s %s" HIJACKED -1 %0.4f\n}

private

def log_hijacking(env, status, header, began_at)
Expand All @@ -54,24 +59,13 @@ def log_hijacking(env, status, header, began_at)
env['HTTP_X_FORWARDED_FOR'] || env["REMOTE_ADDR"] || "-",
env["REMOTE_USER"] || "-",
now.strftime("%d/%b/%Y %H:%M:%S"),
env["REQUEST_METHOD"],
env["PATH_INFO"],
env["QUERY_STRING"].empty? ? "" : "?"+env["QUERY_STRING"],
env[REQUEST_METHOD],
env[PATH_INFO],
env[QUERY_STRING].empty? ? "" : "?#{env[QUERY_STRING]}",
env["HTTP_VERSION"],
now - began_at ]
end

PATH_INFO = 'PATH_INFO'.freeze
REQUEST_METHOD = 'REQUEST_METHOD'.freeze
SCRIPT_NAME = 'SCRIPT_NAME'.freeze
QUERY_STRING = 'QUERY_STRING'.freeze
CACHE_CONTROL = 'Cache-Control'.freeze
CONTENT_LENGTH = 'Content-Length'.freeze
CONTENT_TYPE = 'Content-Type'.freeze

GET = 'GET'.freeze
HEAD = 'HEAD'.freeze

def log(env, status, header, began_at)
now = Time.now
length = extract_content_length(header)
Expand All @@ -82,7 +76,7 @@ def log(env, status, header, began_at)
now.strftime("%d/%b/%Y:%H:%M:%S %z"),
env[REQUEST_METHOD],
env[PATH_INFO],
env[QUERY_STRING].empty? ? "" : "?"+env[QUERY_STRING],
env[QUERY_STRING].empty? ? "" : "?#{env[QUERY_STRING]}",
env["HTTP_VERSION"],
status.to_s[0..3],
length,
Expand Down