This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Add child separator keyword to logging.basicConfig and use it in Logger.getChild()
Type: enhancement Stage:
Components: Library (Lib) Versions: Python 3.6
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: Richard Neumann, vinay.sajip
Priority: normal Keywords: patch

Created on 2016-05-11 13:11 by Richard Neumann, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
logger.patch Richard Neumann, 2016-05-12 10:34
Messages (6)
msg265312 - (view) Author: Richard Neumann (Richard Neumann) Date: 2016-05-11 13:11
Currently Python's logging library has the Child-Separator hard-coded in Logger.getChild() as '.'.
It would be useful to have the ability to preset this via an optional basicConfig() argument like 'child_sep=' and preset it to '.' to retain the current behaviour.
In my case I will need to monkey-patch the getChild() method to use a different separator ('->') because I use '.' for different purposes within the loggers' names.
The current behaviour would lead to ugly and mistakable output.
msg265379 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2016-05-12 08:27
This is a change with wide-ranging ramifications. I don't propose to do this, as the use of '.' as a logging separator mirrors the separator used in the Python package namespace.

Logger names are supposed to indicate the "where" of a logging event - nothing more.
msg265381 - (view) Author: Richard Neumann (Richard Neumann) Date: 2016-05-12 08:40
I am using loggers and sub-loggers (getChild()) in classes, which contain sub-classes, wich contain sub-sub-classes and so on for complex data processing.
Hence I was using the logging library with sub-loggers to see in which of the (sub-)classes things happen.
Most classes are, however, instanced for different configuration and are represented by strings like {instance_config}@{class_name} where {instance_config} often contains dots as separators for IDs.
Example:

INFO	1000@TerminalsSyncer            :	Aggregating customer data: 1031002@Facebook
INFO	1000@TerminalsSyncer            :	Aggregating virtual data: v60.1031002@Config
INFO	1000@TerminalsSyncer            :	Aggregating virtual data: v60.1031002@Presentation
WARNING	1000@TerminalsSyncer->1.1000@TerminalSyncer:	Terminal 1.1000 is offline


However, if you still think that this is not, what the logging library is meant for, I'd appreciate to know.
msg265383 - (view) Author: Richard Neumann (Richard Neumann) Date: 2016-05-12 09:03
PS: @vinay.sajip

You do realize that I want this argument to be optional and to retain '.' as default setting in order to keep the current behaviour?!
msg265385 - (view) Author: Richard Neumann (Richard Neumann) Date: 2016-05-12 09:16
Added proposed patch
msg265433 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2016-05-12 22:57
> However, if you still think that this is not, what the logging library is meant for, I'd appreciate to know.

Confirmed. I would advise against using logger names in this way.
History
Date User Action Args
2022-04-11 14:58:30adminsetgithub: 71186
2016-05-12 22:57:27vinay.sajipsetmessages: + msg265433
2016-05-12 10:34:22Richard Neumannsetfiles: + logger.patch
2016-05-12 09:34:56Richard Neumannsetfiles: - logger.patch
2016-05-12 09:16:17Richard Neumannsetfiles: + logger.patch
keywords: + patch
messages: + msg265385
2016-05-12 09:03:01Richard Neumannsetmessages: + msg265383
2016-05-12 08:40:52Richard Neumannsetmessages: + msg265381
2016-05-12 08:27:57vinay.sajipsetstatus: open -> closed
resolution: wont fix
messages: + msg265379
2016-05-11 18:12:22SilentGhostsetnosy: + vinay.sajip

versions: + Python 3.6, - Python 3.5
2016-05-11 13:11:54Richard Neumannsettitle: Add child seperator keyword to logging.basicConfig and use it in Logger.getChild() -> Add child separator keyword to logging.basicConfig and use it in Logger.getChild()
2016-05-11 13:11:07Richard Neumanncreate