-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve access logging #572
Conversation
Introduce class AccessLogger. Instance of this class is constructed by passing log_format, and used to log messages according to this format. Sample usage: log = logging.getLogger("spam") access_logger = AccessLogger(log, "%a %{User-Agent}i") access_logger.log(message, environ, response, transport, time) Use this object in ServerHttpProtocol for logging.
dccd05d
to
f157e32
Compare
The common time format for logs is: [day/month/year:hour:minute:second zone] day = 2*digit month = 3*letter year = 4*digit hour = 2*digit minute = 2*digit second = 2*digit zone = (`+' | `-') 4*digit
To be consitent with apache, %b should contain output body length without headers. Also add %O variable which contain full output length.
Create AccessLogger instance in RequestHandlerFactory constructor. This avoids initializing AccessLogger per each connection.
"""Return a dash instead of raising KeyError""" | ||
|
||
def __getitem__(self, key): | ||
val = dict.get(self, key.upper()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use upstr(key)
instead of key.upper()
call.
Use cache for faster AccessLogger initialization. Optimize logging process.
New patch added:
Now AccessLogger object is constructed in I can try to move AccessLogger instantiation out of constructor later. |
Cool! |
Introduce class AccessLogger. Instance of this class is
constructed by passing log_format, and used to log messages
according to this format.
Usage:
Use this object in ServerHttpProtocol for logging.
Also closed #458