[Twisted-Python] Question on log time stamp precision
exarkun at twistedmatrix.com
exarkun at twistedmatrix.com
Mon Jan 20 12:35:56 MST 2014
On 02:16 am, dustin at v.igoro.us wrote:
>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.
If you have a tac file, set it yourself. If you're using a twistd
plugin, use the `--logger` option:
https://twistedmatrix.com/documents/current/core/howto/application.html#auto5
Jean-Paul
More information about the Twisted-Python
mailing list