Skip to content
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

Changing logging format for one handler changes it for all #88765

Closed
hyamanieu mannequin opened this issue Jul 11, 2021 · 3 comments
Closed

Changing logging format for one handler changes it for all #88765

hyamanieu mannequin opened this issue Jul 11, 2021 · 3 comments
Labels
3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@hyamanieu
Copy link
Mannequin

hyamanieu mannequin commented Jul 11, 2021

BPO 44599
Nosy @vsajip

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2021-07-12.05:39:28.522>
created_at = <Date 2021-07-11.17:12:20.384>
labels = ['type-bug', '3.8', '3.9', 'invalid', '3.7', 'library']
title = 'Changing logging format for one handler changes it for all'
updated_at = <Date 2021-07-12.07:31:56.269>
user = 'https://bugs.python.org/hyamanieu'

bugs.python.org fields:

activity = <Date 2021-07-12.07:31:56.269>
actor = 'hyamanieu'
assignee = 'none'
closed = True
closed_date = <Date 2021-07-12.05:39:28.522>
closer = 'vinay.sajip'
components = ['Library (Lib)']
creation = <Date 2021-07-11.17:12:20.384>
creator = 'hyamanieu'
dependencies = []
files = []
hgrepos = []
issue_num = 44599
keywords = []
message_count = 3.0
messages = ['397258', '397282', '397288']
nosy_count = 2.0
nosy_names = ['vinay.sajip', 'hyamanieu']
pr_nums = []
priority = 'normal'
resolution = 'not a bug'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue44599'
versions = ['Python 3.7', 'Python 3.8', 'Python 3.9']

@hyamanieu
Copy link
Mannequin Author

hyamanieu mannequin commented Jul 11, 2021

I want to stream a logger to several streams. Changing the standard format works, but changing the formatException function changes it for all!

As I am not entirely sure if it is a feature and I am misunderstanding something, I have posted on SO on this topic: https://stackoverflow.com/questions/68244691/changing-logging-format-for-one-handler-changes-it-for-all

It looks like an unexpected behavior to me when reading the doc.

@hyamanieu hyamanieu mannequin added 3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Jul 11, 2021
@vsajip
Copy link
Member

vsajip commented Jul 12, 2021

It looks like an unexpected behavior to me when reading the doc.

Perhaps you missed this?

https://docs.python.org/3/library/logging.html?highlight=exc_text#logging.Formatter.format

"Note that the formatted exception information is cached in attribute exc_text. This is useful because the exception information can be pickled and sent across the wire, but you should be careful if you have more than one Formatter subclass which customizes the formatting of exception information. In this case, you will have to clear the cached value after a formatter has done its formatting, so that the next formatter to handle the event doesn’t use the cached value but recalculates it afresh."

@hyamanieu
Copy link
Mannequin Author

hyamanieu mannequin commented Jul 12, 2021

Yes I did miss that. My bad and thank you so much.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant