[Python-Dev] Proposed change to logging

Barry Warsaw barry at python.org
Tue Aug 24 18:49:54 CEST 2004


On Tue, 2004-08-24 at 09:57, Vinay Sajip wrote:
> An improvement to logging has been proposed by Miki
> Tebeka, which involves the creation of file-like
> wrapper objects for loggers. 

Yay! +1, especially if I can use them interchangeably.  In my code, I
usually like the log.debug() calls, but once in a while I have output
that comes from something expecting a file-like API, and in that case,
it would be nice to be able to pass in log.getFileObject().  Currently,
I'm StringIO'ing it.

> There's
> one wart in the implementation - to avoid printing out
> blank lines caused by the "\n" appended by print, we
> ignore messages which are == "\n". This works only
> because print does a separate write for the "\n". Can
> anyone see a problem with this approach?

What if the .log() method on loggers took an extra flag to suppress the
newline or not, and the wrapper's .write() method passed the appropriate
value?  The default would be to include the extra newline so the .log()
interface would be backward compatible.

-Barry

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 307 bytes
Desc: This is a digitally signed message part
Url : http://mail.python.org/pipermail/python-dev/attachments/20040824/e08fbcaa/attachment-0001.pgp


More information about the Python-Dev mailing list