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.

Author vinay.sajip
Recipients BreamoreBoy, Saimadhav.Heblikar, pitrou, vinay.sajip
Date 2014-08-14.23:25:53
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1408058754.4.0.428263236843.issue22195@psf.upfronthosting.co.za>
In-reply-to
Content
This is easy enough to do, I posted about it in 2009 here:

http://plumberjack.blogspot.co.uk/2009/09/how-to-treat-logger-like-output-stream.html

Basically, something like

class LoggerWriter(object):
    def __init__(self, logger, level):
        self.logger = logger
        self.level = level

    def write(self, message):
        if message != '\n':
            self.logger.log(self.level, message)

    def flush(self):
        pass

I'm not sure something like this really needs to be in the stdlib.

Loggers shouldn't have a method with a print-like signature, since it's Handlers that are concerned with output destinations such as streams.
History
Date User Action Args
2014-08-14 23:25:54vinay.sajipsetrecipients: + vinay.sajip, pitrou, BreamoreBoy, Saimadhav.Heblikar
2014-08-14 23:25:54vinay.sajipsetmessageid: <1408058754.4.0.428263236843.issue22195@psf.upfronthosting.co.za>
2014-08-14 23:25:54vinay.sajiplinkissue22195 messages
2014-08-14 23:25:53vinay.sajipcreate