logging module and trailing newlines
Russell Warren
russandheather at gmail.com
Tue Oct 2 18:07:17 EDT 2007
I was just setting up some logging in a make script and decided to
give the built-in logging module a go, but I just found out that the
base StreamHandler always puts a newline at the end of each log.
There is a comment in the code that says "The record is then written
to the stream with a trailing newline [N.B. this may be removed
depending on feedback]"... I guess there wasn't the feedback to drive
the change.
All I'm after is the ability to log things like...
Compiling 'shrubbery.c'... [DONE]
where the "[DONE]" was added later in time than the "Compiling...",
and the output goes to both stdout and to a log file. ie: I want to
tee my print statements and keep the ability to skip the trailing
newline. I had rolled my own primitive version than decided to try
the logging module for kicks.
Anyone have a suggestion on how to get logging to work like this? Or
know of a way to tee in Windows without forcing other users to install
a tee package?
More information about the Python-list
mailing list