Custom logging function

DL Neil PythonList at DancesWithMice.info
Mon May 25 16:49:01 EDT 2020


On 26/05/20 8:26 AM, zljubisic at gmail.com wrote:
> Hi,
> 
> I have a case in which I have to use custom function for logging.
> For example, all messages should go to stderr and end with '\r\n'.
> 
> Can I somehow use standard python logging module but send all message to stderr with '\r\n' line endings?


- use a logging formatter (with the below, linesep) to construct 
log.msgs (and their endings)
- use the logging library's helper function to direct log.msgs to stderr 
(or wherever)


os.linesep in The Python Standard Library: os — Miscellaneous operating 
system interfaces
https://docs.python.org/3/library/os.html


stderr is the default destination for logging
Logging HOWTO https://docs.python.org/3/howto/logging.html
https://docs.python.org/3/library/logging.html

-- 
Regards =dn


More information about the Python-list mailing list