Display timezones in local time
This commit is contained in:
parent
574a99f79d
commit
60f8965ab4
13
CHANGELOG.md
13
CHANGELOG.md
|
@ -2,13 +2,16 @@
|
|||
|
||||
### Unreleased
|
||||
|
||||
- The server will now return a redirect if a directory is requested but the URL
|
||||
does not end in a trailing slash. This reduces duplicate selectors and makes
|
||||
it easier for clients to resolve relative links.
|
||||
- Added a ``-V`` / ``--version`` argument to display the version and exit.
|
||||
- The server now returns a ``50 PERMENANT FAILURE`` response when a client
|
||||
requests a URL that does not exist on the server. This change is motivated by
|
||||
mailing list discussions that a ``51 NOT FOUND`` status may not be
|
||||
appropriate if the scheme/host component of the URL does not match the server.
|
||||
- Added ``-V`` / ``--version`` argument to display the version and exit.
|
||||
- Force URLs to always end in trailing slashes when serving a directory. This
|
||||
reduces duplicate selectors and makes resolving relative links more reliable.
|
||||
the suggestion that a ``51 NOT FOUND`` status might not always be appropriate
|
||||
if the scheme/host component of the URL does not match.
|
||||
- Timestamps in log messages are now displayed to the server's local timezone.
|
||||
The UTC offset is included in the timestamp as "+HHMM" to prevent ambiguity.
|
||||
|
||||
### v0.0.7 (2019-08-30)
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ import ssl
|
|||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import time
|
||||
import typing
|
||||
import urllib.parse
|
||||
|
||||
|
@ -339,12 +340,14 @@ class GeminiRequestHandler:
|
|||
removed or slimmed-down.
|
||||
"""
|
||||
|
||||
TIMESTAMP_FORMAT = "%d/%b/%Y:%H:%M:%S %z"
|
||||
|
||||
def __init__(self, server: GeminiServer, app: typing.Callable) -> None:
|
||||
self.server = server
|
||||
self.app = app
|
||||
self.reader: typing.Optional[asyncio.StreamReader] = None
|
||||
self.writer: typing.Optional[asyncio.StreamWriter] = None
|
||||
self.received_timestamp: typing.Optional[datetime.datetime] = None
|
||||
self.received_timestamp: typing.Optional[time.struct_time] = None
|
||||
self.remote_addr: typing.Optional[str] = None
|
||||
self.client_cert: typing.Optional[dict] = None
|
||||
self.url: typing.Optional[urllib.parse.ParseResult] = None
|
||||
|
@ -367,7 +370,7 @@ class GeminiRequestHandler:
|
|||
self.writer = writer
|
||||
self.remote_addr = writer.get_extra_info("peername")[0]
|
||||
self.client_cert = writer.get_extra_info("peercert")
|
||||
self.received_timestamp = datetime.datetime.utcnow()
|
||||
self.received_timestamp = time.localtime()
|
||||
|
||||
try:
|
||||
await self.parse_header()
|
||||
|
@ -481,7 +484,7 @@ class GeminiRequestHandler:
|
|||
"""
|
||||
self.server.log_message(
|
||||
f"{self.remote_addr} "
|
||||
f"[{self.received_timestamp:%d/%b/%Y:%H:%M:%S +0000}] "
|
||||
f"[{time.strftime(self.TIMESTAMP_FORMAT, self.received_timestamp)}] "
|
||||
f'"{self.url}" '
|
||||
f"{self.status} "
|
||||
f'"{self.meta}" '
|
||||
|
|
Loading…
Reference in New Issue