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

Update log message formatting. #49442

Closed
lambertdw mannequin opened this issue Feb 9, 2009 · 2 comments
Closed

Update log message formatting. #49442

lambertdw mannequin opened this issue Feb 9, 2009 · 2 comments
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@lambertdw
Copy link
Mannequin

lambertdw mannequin commented Feb 9, 2009

BPO 5192
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 2009-02-17.19:29:56.073>
created_at = <Date 2009-02-09.16:44:10.965>
labels = ['type-feature', 'library']
title = 'Update log message formatting.'
updated_at = <Date 2009-02-19.12:43:06.226>
user = 'https://bugs.python.org/LambertDW'

bugs.python.org fields:

activity = <Date 2009-02-19.12:43:06.226>
actor = 'vinay.sajip'
assignee = 'none'
closed = True
closed_date = <Date 2009-02-17.19:29:56.073>
closer = 'vinay.sajip'
components = ['Library (Lib)']
creation = <Date 2009-02-09.16:44:10.965>
creator = 'LambertDW'
dependencies = []
files = []
hgrepos = []
issue_num = 5192
keywords = []
message_count = 2.0
messages = ['81461', '82360']
nosy_count = 2.0
nosy_names = ['vinay.sajip', 'LambertDW']
pr_nums = []
priority = 'normal'
resolution = 'rejected'
stage = None
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue5192'
versions = ['Python 3.0', 'Python 3.1']

@lambertdw
Copy link
Mannequin Author

lambertdw mannequin commented Feb 9, 2009

Allow logger object log message creation methods using ''.format method.

have:

logger_object.info('%s','lazy is better')
logger_object.debug('{0!s}'.format('wasted effort'))

want:

logger_object.debug('{0}','Lazy')

Work'rounds from PEP-282:

if log.isEnabledFor(logging.INFO):
            hamletStr = hamletDom.toxml()
            log.info(hamletStr)

or install custom Formatter.

I presume this is already on the back burner.

Incidentally, BufferingFormatter.format uses string += string instead of
''.join(list_of_strings).

@lambertdw lambertdw mannequin added stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Feb 9, 2009
@vsajip
Copy link
Member

vsajip commented Feb 17, 2009

Isn't there a backward compatibility problem? If a message format string
contains both "%s" and "{0}", how is logging supposed to know what to
use - a % b or a.format(b)?

The way to do it is a custom Formatter, as you've indicated.

@vsajip vsajip closed this as completed Feb 17, 2009
@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

1 participant