Message225324
| 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:54 | vinay.sajip | set | recipients:
+ vinay.sajip, pitrou, BreamoreBoy, Saimadhav.Heblikar |
| 2014年08月14日 23:25:54 | vinay.sajip | set | messageid: <1408058754.4.0.428263236843.issue22195@psf.upfronthosting.co.za> |
| 2014年08月14日 23:25:54 | vinay.sajip | link | issue22195 messages |
| 2014年08月14日 23:25:53 | vinay.sajip | create |
|