Skip to content
Myr

Merge remote-tracking branch 'origin/1.0.x'

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Lord · committed by David Lord · parents 48d0e86, 6369537 · Browse files · 1 file+9 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+9 added−4 removed

  • other:+9 added−4 removed

1 file+9 added−4 removed

modified:docs/logging.rst+9 added-4 removed
115 unmodified lines
116your own fields that can be used in messages. You can change the formatter for117Flask's default handler, the mail handler defined above, or any other118handler. ::119120 from flask import request120 from flask import has_request_context, request121 from flask.logging import default_handler122123 class RequestFormatter(logging.Formatter):124 def format(self, record):125 if has_request_context():125 record.url = request.url126 record.remote_addr = request.remote_addr127 return super(RequestFormatter, self).format(record)126 record.url = request.url127 record.remote_addr = request.remote_addr128 else:129 record.url = None130 record.remote_addr = None131132 return super().format(record)133134 formatter = RequestFormatter(135 '[%(asctime)s] %(remote_addr)s requested %(url)s\n'136 '%(levelname)s in %(module)s: %(message)s'137 )
43 unmodified lines