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.

Title: Add set_terminate() to logging
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.9
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: vinay.sajip, wyz23x2
Priority: normal Keywords:

Created on 2020-03-08 01:45 by wyz23x2, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (3)
msg363622 - (view) Author: wyz23x2 (wyz23x2) * Date: 2020-03-08 01:45
Sometimes, we want to remove the ending \n and sometimes replace it wit something else, like print(). But logging doesn't support that.
I'd want a set_terminate() (Or set_end()) function that does that. I think it's easy. Just insert this at line 1119 of __init__ of 3.8.2:
def set_terminator(string='\n'):
    StreamHandler.terminator = string
msg363623 - (view) Author: wyz23x2 (wyz23x2) * Date: 2020-03-08 01:48
typo: "with something else", not "wit something else". Sorry for that.
msg363731 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2020-03-09 13:58
There's no need for a method to do this. You can do any of:

1. Set the terminator attribute to whatever you need in logging.StreamHandler (if all code you ever use must use a different terminator).

2. Set it in individual instances of StreamHandler.

3. Set it in a subclass of StreamHandler which you then use instead of StreamHandler.

Since only a few cases will want a different terminator, there's no need to add a special mechanism to override it, when you can just use an assignment statement.
Date User Action Args
2022-04-11 14:59:27adminsetgithub: 84074
2020-03-09 13:58:49vinay.sajipsetstatus: open -> closed
versions: - Python 3.5, Python 3.6, Python 3.7, Python 3.8
messages: + msg363731

resolution: rejected
stage: resolved
2020-03-09 13:34:01xtreaksetnosy: + vinay.sajip
2020-03-09 12:25:05wyz23x2setversions: + Python 3.5, Python 3.6, Python 3.7
2020-03-08 01:48:58wyz23x2setmessages: + msg363623
2020-03-08 01:45:28wyz23x2create