Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ jobs:
strategy:
matrix:
include:
- python: 2.7
env: py27
- python: 3.5
env: py35
- python: 3.6
Expand Down
12 changes: 10 additions & 2 deletions paste/translogger.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,14 @@ class TransLogger(object):

If ``setup_console_handler`` is true, then messages for the named
logger will be sent to the console.

To adjust the format of the timestamp in the log, provide a strftime
format string to the ``time_format`` keyword argument. Otherwise
``default_time_format`` will be used.
"""

default_time_format = '%d/%b/%Y:%H:%M:%S '

format = ('%(REMOTE_ADDR)s - %(REMOTE_USER)s [%(time)s] '
'"%(REQUEST_METHOD)s %(REQUEST_URI)s %(HTTP_VERSION)s" '
'%(status)s %(bytes)s "%(HTTP_REFERER)s" "%(HTTP_USER_AGENT)s"')
Expand All @@ -29,9 +35,11 @@ def __init__(self, application,
logging_level=logging.INFO,
logger_name='wsgi',
setup_console_handler=True,
set_logger_level=logging.DEBUG):
set_logger_level=logging.DEBUG,
time_format=None):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not assign the default right here?

Suggested change
time_format=None):
time_format=default_time_format):

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically just to keep the same pattern used for format in line 28/34.

Which is perhaps not sufficient reason technically, but I tend to want to stick with existing patterns, especially in paste where everything is so weird and old and sometimes confusing.

Thus minimal changes.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, thank you.

if format is not None:
self.format = format
self.time_format = time_format or self.default_time_format
self.application = application
self.logging_level = logging_level
self.logger_name = logger_name
Expand Down Expand Up @@ -90,7 +98,7 @@ def write_log(self, environ, method, req_uri, start, status, bytes):
'REQUEST_METHOD': method,
'REQUEST_URI': req_uri,
'HTTP_VERSION': environ.get('SERVER_PROTOCOL'),
'time': time.strftime('%d/%b/%Y:%H:%M:%S ', start) + offset,
'time': time.strftime(self.time_format, start) + offset,
'status': status.split(None, 1)[0],
'bytes': bytes,
'HTTP_REFERER': environ.get('HTTP_REFERER', '-'),
Expand Down