Split out access logs, fixes #37

This commit is contained in:
Michael Lazar 2020-07-14 01:00:51 -04:00
parent 57556e09f5
commit 7215195b8c
4 changed files with 12 additions and 5 deletions

View File

@ -2,7 +2,10 @@
### Unreleased
- Optimized chunking for streaming large files.
- File chunking has been optimized for streaming large static files.
- Server access logs are now redirected to ``stdout`` instead of ``stderr``.
This is intended to make it easier to use a log manager tool to split them
out from other server messages like startup information and error tracebacks.
### v0.5.0 (2020-07-14)

View File

@ -6,8 +6,6 @@ import subprocess
import typing
import urllib.parse
from twisted.protocols.basic import FileSender
from .base import JetforceApplication, Request, Response, RoutePattern, Status

View File

@ -288,4 +288,4 @@ class GeminiProtocol(LineOnlyReceiver):
# The connection ended before we got far enough to log anything
pass
else:
self.server.log_message(message)
self.server.log_access(message)

View File

@ -73,9 +73,15 @@ class GeminiServer(Factory):
self.cafile = cafile
self.capath = capath
def log_access(self, message: str) -> None:
"""
Log standard "access log"-type information.
"""
print(message, file=sys.stdout)
def log_message(self, message: str) -> None:
"""
Log a diagnostic server message to stderr.
Log special messages like startup info or a traceback error.
"""
print(message, file=sys.stderr)