Skip to content

Commit

Permalink
Align access log format across protocols
Browse files Browse the repository at this point in the history
  • Loading branch information
gi0baro committed May 24, 2024
1 parent 564d1ae commit e0133b8
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions granian/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ def access_log(t, scope, resp_code):
logger(
t,
{
'addr_remote': scope['client'],
'protocol': scope['http_version'],
'addr_remote': scope['client'][0],
'protocol': 'HTTP/' + scope['http_version'],
'path': scope['path'],
'qs': scope['query_string'],
'method': scope['method'],
Expand Down
4 changes: 2 additions & 2 deletions granian/rsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ def access_log(t, scope, resp_code):
logger(
t,
{
'addr_remote': scope.client,
'protocol': scope.http_version,
'addr_remote': scope.client.split(':')[0],
'protocol': 'HTTP/' + scope.http_version,
'path': scope.path,
'qs': scope.query_string,
'method': scope.method,
Expand Down
4 changes: 2 additions & 2 deletions granian/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def __init__(
log_level: LogLevels = LogLevels.info,
log_dictconfig: Optional[Dict[str, Any]] = None,
log_access: bool = False,
log_access_format: str = DEFAULT_ACCESSLOG_FMT,
log_access_format: Optional[str] = None,
ssl_cert: Optional[Path] = None,
ssl_key: Optional[Path] = None,
url_path_prefix: Optional[str] = None,
Expand Down Expand Up @@ -113,7 +113,7 @@ def __init__(
self.log_level = log_level
self.log_config = log_dictconfig
self.log_access = log_access
self.log_access_format = log_access_format
self.log_access_format = log_access_format or DEFAULT_ACCESSLOG_FMT
self.url_path_prefix = url_path_prefix
self.respawn_failed_workers = respawn_failed_workers
self.reload_on_changes = reload
Expand Down
2 changes: 1 addition & 1 deletion granian/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def access_log(t, scope, resp_code):
logger(
t,
{
'addr_remote': scope['REMOTE_ADDR'],
'addr_remote': scope['REMOTE_ADDR'].split(':')[0],
'protocol': scope['SERVER_PROTOCOL'],
'path': scope['PATH_INFO'],
'qs': scope['QUERY_STRING'],
Expand Down

0 comments on commit e0133b8

Please sign in to comment.