classification
Title: logging style parameter does not work correctly
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.4, Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: vinay.sajip Nosy List: kespindler, python-dev, vinay.sajip
Priority: normal Keywords: patch

Created on 2014-01-13 18:41 by kespindler, last changed 2014-01-13 22:01 by python-dev. This issue is now closed.

Files
File name Uploaded Description Edit
Issue20242.patch kespindler, 2014-01-13 18:48 review
Messages (5)
msg208035 - (view) Author: (kespindler) Date: 2014-01-13 18:41
In Python 3.3, 3.4beta2, and bleeding edge (88411:e7d922d8ee03), the following occurs 

>>> import logging
>>> logging.basicConfig(style="{")
>>> logging.error("hello")
%(levelname)s:%(name)s:%(message)s


Of course, I would expect

ERROR:root:hello

to be output instead.
msg208038 - (view) Author: (kespindler) Date: 2014-01-13 18:48
I created a patch that fixes this behavior for both { and $ style formats.

Previously, default format strings were not being set correctly for those styles. This patch ensures that the correct default_format string is used.

There is a minor "weirdness" issue that, due to there previously being 2 different default format strings for % style formatting, some tests rely on one, and some tests rely on the other. My patch remains backwards compatible with both default styles of format strings.

This patch also includes test cases for behavior with the style keyword, which was not being tested before.
msg208048 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2014-01-13 21:20
Thanks for this. The patch looks good, and I expect to implement it shortly.
msg208049 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2014-01-13 21:54
On further reflection, I will implement this slightly differently. The tests I will commit as is, except for stripping newlines before the comparison (to avoid worrying about differences in line separators across different platforms). However, the correct fix IMO is to add the default format strings to the _STYLES dict values: the effect should be the same.
msg208050 - (view) Author: Roundup Robot (python-dev) Date: 2014-01-13 22:01
New changeset e7fcf0d8008f by Vinay Sajip in branch '3.3':
Issue #20242: Fixed basicConfig() format strings for the alternative formatting styles.
http://hg.python.org/cpython/rev/e7fcf0d8008f

New changeset c1605d24fb35 by Vinay Sajip in branch 'default':
Closes #20242: Merged fix from 3.3.
http://hg.python.org/cpython/rev/c1605d24fb35
History
Date User Action Args
2014-01-13 22:01:29python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg208050

resolution: fixed
stage: resolved
2014-01-13 21:54:55vinay.sajipsetmessages: + msg208049
2014-01-13 21:20:30vinay.sajipsetassignee: vinay.sajip
messages: + msg208048
2014-01-13 19:09:45ned.deilysetnosy: + vinay.sajip
2014-01-13 18:48:07kespindlersetfiles: + Issue20242.patch
keywords: + patch
messages: + msg208038
2014-01-13 18:41:50kespindlercreate