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
|
### 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
|
- 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
|
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
|
the suggestion that a ``51 NOT FOUND`` status might not always be appropriate
|
||||||
appropriate if the scheme/host component of the URL does not match the server.
|
if the scheme/host component of the URL does not match.
|
||||||
- Added ``-V`` / ``--version`` argument to display the version and exit.
|
- Timestamps in log messages are now displayed to the server's local timezone.
|
||||||
- Force URLs to always end in trailing slashes when serving a directory. This
|
The UTC offset is included in the timestamp as "+HHMM" to prevent ambiguity.
|
||||||
reduces duplicate selectors and makes resolving relative links more reliable.
|
|
||||||
|
|
||||||
### v0.0.7 (2019-08-30)
|
### v0.0.7 (2019-08-30)
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ import ssl
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
|
import time
|
||||||
import typing
|
import typing
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
|
|
||||||
|
@ -339,12 +340,14 @@ class GeminiRequestHandler:
|
||||||
removed or slimmed-down.
|
removed or slimmed-down.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
TIMESTAMP_FORMAT = "%d/%b/%Y:%H:%M:%S %z"
|
||||||
|
|
||||||
def __init__(self, server: GeminiServer, app: typing.Callable) -> None:
|
def __init__(self, server: GeminiServer, app: typing.Callable) -> None:
|
||||||
self.server = server
|
self.server = server
|
||||||
self.app = app
|
self.app = app
|
||||||
self.reader: typing.Optional[asyncio.StreamReader] = None
|
self.reader: typing.Optional[asyncio.StreamReader] = None
|
||||||
self.writer: typing.Optional[asyncio.StreamWriter] = 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.remote_addr: typing.Optional[str] = None
|
||||||
self.client_cert: typing.Optional[dict] = None
|
self.client_cert: typing.Optional[dict] = None
|
||||||
self.url: typing.Optional[urllib.parse.ParseResult] = None
|
self.url: typing.Optional[urllib.parse.ParseResult] = None
|
||||||
|
@ -367,7 +370,7 @@ class GeminiRequestHandler:
|
||||||
self.writer = writer
|
self.writer = writer
|
||||||
self.remote_addr = writer.get_extra_info("peername")[0]
|
self.remote_addr = writer.get_extra_info("peername")[0]
|
||||||
self.client_cert = writer.get_extra_info("peercert")
|
self.client_cert = writer.get_extra_info("peercert")
|
||||||
self.received_timestamp = datetime.datetime.utcnow()
|
self.received_timestamp = time.localtime()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await self.parse_header()
|
await self.parse_header()
|
||||||
|
@ -481,7 +484,7 @@ class GeminiRequestHandler:
|
||||||
"""
|
"""
|
||||||
self.server.log_message(
|
self.server.log_message(
|
||||||
f"{self.remote_addr} "
|
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.url}" '
|
||||||
f"{self.status} "
|
f"{self.status} "
|
||||||
f'"{self.meta}" '
|
f'"{self.meta}" '
|
||||||
|
|
Loading…
Reference in New Issue