[Twisted-Python] Question on log time stamp precision

Dustin J. Mitchell dustin at v.igoro.us
Sun Jan 19 19:16:33 MST 2014


On Sun, Jan 19, 2014 at 8:55 PM,  <exarkun at twistedmatrix.com> wrote:
> On 19 Jan, 11:47 pm, dustin at v.igoro.us wrote:
>>>
>>> From what I can tell in a few old bugs and the API docs, the key is to
>>
>> monkey-patch log.FileLogObserver.timeFormat.
>
>
> Or just politely set it on the instance of FileLogObserver your application
> creates so as to avoid global side-effects. :)

Ah, which is returned from startLogging, so

--
from twisted.python import log

lo = log.startLogging(sys.stdout)
lo.formatTime = lambda when:
datetime.datetime.fromtimestamp(when).strftime("%H:%M:%S.%f")

log.msg("Hello!")
--

I'm not sure how you'd find that object under Twistd, though.

Dustin



More information about the Twisted-Python mailing list