twisted python logging issue / confusion? -
i have smtp server based around http://twistedmatrix.com/documents/current/_downloads/emailserver.tac
this incorporates "custom_esmtp.py", contains overloaded versions of of classes found in twisted's smtp.py - included allow classes there no overloaded version.
by default, there no log.startlogging line in of above 3 mentioned files. however, basic log output stdout:
> # twistd -ny mailserver.tac 2014-10-29 15:35:53+0000 [-] log opened. 2014-10-29 15:35:53+0000 [-] twistd 14.0.0 (/usr/bin/python 2.6.6) starting up. 2014-10-29 15:35:53+0000 [-] reactor class: twisted.internet.epollreactor.epollreactor. 2014-10-29 15:35:53+0000 [-] consolesmtpfactory starting on 25 2014-10-29 15:35:53+0000 [-] starting mill <__builtin__.consolesmtpfactory instance @ 0x31d67a0> 2014-10-29 15:35:55+0000 [mysmtp,0,127.0.0.1] receiving myesmtp message delivery: from=user1@nonpurdomain1.mta.test to=['user1@prefix-subject.domain.reg.test']
i assume sort of standard level twisted logging - open beingness corrected.
however, if add:
> log.startlogging(sys.stdout)
to main method of emailserver.tac (with required import statement of course) - flood of thousands of log entries seem date/time stamp of empty log line:
[-] 2014-10-29 15:15:20+0000 [-] 2014-10-29 15:15:20+0000 [-] 2014-10-29 15:15:20+0000 [-] 2014-10-29 15:15:20+0000 [-] 2014-10-29 15:15:20+0000 [-] 2014-10-29 15:15:20+0000 [-] 2014-10-29 15:15:20+0000 [-] 2014-10-29 15:15:20+0000 [-] 2014-10-29 15:15:20+0000 [-] 2014-10-29 15:15:20+0000
can offer reason why / happening? significance of [-] - assume when there no connected client... when there is, become 3 values shown - , 2nd value??
kinda lost here, , looking understand how logging working, can tweak meet our requirements.
thanks!
you can seek this:
log.discardlogs() log.startlogging(sys.stdout)
first thing twistd runner calls log.startlogging(...) in internals. sec thing every time log.startlogging(...) called writes initial message opened log stream.
because of u'r running twistd in debug mode (-n) twistd makes exact phone call log.startlogging(sys.stdout). when log.startlogging(...) called twice, sec phone call tries write initial message written first logger , effect have seen happens.
however, don't need phone call log.startlogging(...), should utilize 1 of twistd options:
-l, --logfile= log specified file, - stdout --logger= fully-qualified name log observer mill utilize initial log observer. takes precedence on --logfile , --syslog (when available).
also have no chances remove first 3 strings log, while using twistd.
2014-10-29 15:35:53+0000 [-] log opened. 2014-10-29 15:35:53+0000 [-] twistd 14.0.0 (/usr/bin/python 2.6.6) starting up. 2014-10-29 15:35:53+0000 [-] reactor class: twisted.internet.epollreactor.epollreactor.
but mill output can muted setting protocol noisy attribute:
consolesmtpfactory.protocol.noisy = false
i hope help , give understanding of twisted logging.
python logging twisted
No comments:
Post a Comment