Skip to content

Update log message formatting. #49442

Closed
Closed

Description

@lambertdw
mannequin
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']

Activity

  1. lambertdw commented on Feb 9, 2009

    lambertdwmannequin
    MannequinAuthor

    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).

  2. added
    stdlibStandard Library Python modules in the Lib/ directory
    type-featureA feature request or enhancement
    on Feb 9, 2009
  3. vsajip commented on Feb 17, 2009

    @vsajip
    Member

    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.

  4. transferred this issue fromon Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions