-
-
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
Reduce access log overhead when logging is disabled with a logging filter #7251
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
If the logger was disabled the log message would be formatted and thrown away. Avoid formatting the log message when logging is not enabled at info level.
Co-authored-by: Sviatoslav Sydorenko <wk.cvs.github@sydorenko.org.ua>
psf-chronographer
bot
added
the
bot:chronographer:provided
There is a change note present in this PR
label
Apr 8, 2023
5 tasks
bdraco
changed the title
Reduce access log overhead when logging is disabled
Reduce access log overhead when logging is disabled with a logging filter
Apr 8, 2023
After writing out |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
alternative to #7240
What do these changes do?
If the logger was disabled the log message would be formatted and thrown away. Avoid formatting the log message when logging is not enabled at info level.
Are there changes in behavior for the user?
If you are using multiple
aiohttp.web.AppRunner
in the same python process you must also now pass a unique logger to each becauseAccessLogger
will now attach a filter which affects the state of any logger object passed in and is not re-entrant.Consumers of
AccessLogger
MUST use a new unique logger as theAccessLogger
will now add logging filter to any existing logger that is passed in which will affect logging for all handlers attached to that logger. Be sure to generate a unique logger object for each instance of AccessLogger. It is important the logger is unique because if other code is using the same logger, the logging filter will likely raise an exception or mutate the log messages in an unexpected way.If multiple aiohttp instances use the same logger object then the log filter will be attached multiple times which will lead to undefined behavior.
Related issue number
Checklist
CONTRIBUTORS.txt
CHANGES
folder<issue_id>.<type>
for example (588.bugfix)issue_id
change it to the pr id after creating the pr.feature
: Signifying a new feature..bugfix
: Signifying a bug fix..doc
: Signifying a documentation improvement..removal
: Signifying a deprecation or removal of public API..misc
: A ticket has been closed, but it is not of interest to users.