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

Nicer default logging format #89845

Closed
olafvdspek mannequin opened this issue Oct 31, 2021 · 5 comments
Closed

Nicer default logging format #89845

olafvdspek mannequin opened this issue Oct 31, 2021 · 5 comments
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@olafvdspek
Copy link
Mannequin

olafvdspek mannequin commented Oct 31, 2021

BPO 45682
Nosy @rhettinger, @vsajip, @OlafvdSpek

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-10-31.17:52:38.105>
created_at = <Date 2021-10-31.13:55:19.781>
labels = ['type-feature', 'library']
title = 'Nicer default logging format'
updated_at = <Date 2021-10-31.20:09:01.914>
user = 'https://github.com/olafvdspek'

bugs.python.org fields:

activity = <Date 2021-10-31.20:09:01.914>
actor = 'vinay.sajip'
assignee = 'none'
closed = True
closed_date = <Date 2021-10-31.17:52:38.105>
closer = 'vinay.sajip'
components = ['Library (Lib)']
creation = <Date 2021-10-31.13:55:19.781>
creator = 'olafvdspek'
dependencies = []
files = []
hgrepos = []
issue_num = 45682
keywords = []
message_count = 5.0
messages = ['405403', '405404', '405412', '405418', '405419']
nosy_count = 3.0
nosy_names = ['rhettinger', 'vinay.sajip', 'olafvdspek']
pr_nums = []
priority = 'normal'
resolution = 'rejected'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue45682'
versions = []

@olafvdspek
Copy link
Mannequin Author

olafvdspek mannequin commented Oct 31, 2021

The default logging format will print something like:
WARNING:root:Hello Python!

Could it default to something like this instead?

2021-10-31 14:52:36,490 WARNING: Hello Python!

logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s')
logging.warning('Hello Python!')

@olafvdspek olafvdspek mannequin added stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Oct 31, 2021
@rhettinger
Copy link
Contributor

Generally, we can't change defaults after an API has been published because it immediately affects the output for people who use that default. However in the case of logging, an argument could be made that changing the default would have less impact.

@vsajip
Copy link
Member

vsajip commented Oct 31, 2021

However in the case of logging, an argument could be made that changing the default would have less impact.

Except that people may have used the current basic format in, for example, unit tests, and that code could break after a change like the one proposed. The default has been intentionally kept minimal for the very simplest of needs and it is easy to override this default using e.g. basicConfig() for simple needs or e.g. dictConfig() for more elaborate needs.

For those reasons, I don't think this default should be changed.

@vsajip vsajip closed this as completed Oct 31, 2021
@vsajip vsajip closed this as completed Oct 31, 2021
@olafvdspek
Copy link
Mannequin Author

olafvdspek mannequin commented Oct 31, 2021

Except that people may have used the current basic format in, for example, unit tests, and that code could break after a change like the one proposed.

They too could pass a format argument themselves rather then relying on the default format never changing.

@vsajip
Copy link
Member

vsajip commented Oct 31, 2021

They too could pass a format argument themselves rather then relying on the default format never changing.

Changes to the stdlib shouldn't require changing previously working code (sometimes months or years old) to fix breakage caused by new stdlib changes.

@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
stdlib Python modules in the Lib dir type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants