1

I need to know the time delta between 2 events. I'm using logging in a script like this:

format='%(created)f % (message)s'. 

This returned me epoch time in seconds BUT in my case time delta sometime more and sometime less that a second hence it didn't work. Then I changed it for this:

format='%(msecs)d % (message)s'

It returned me msecs but it also didn't always work when time delta more than a second.

Hence my request is: I need time format operator during logging that would return me epoch time in milliseconds and I could reliably get accurate time delta. It also could be not epoch time but anytime expressed in millisecond that I could do simple subtract operation.

4
  • Can I give you some advice? I suppose so. You should break your question into paragraphs.
    – don.joey
    Jan 25, 2015 at 15:28
  • sorry, question #1: what format operator to use in logging module in order to get time in milliseconds
    – susja
    Jan 25, 2015 at 15:46
  • I am probably not getting the situation correctly, but why not just calculate with (the difference in) datetime.datetime.now() Jan 25, 2015 at 18:44
  • This could be an idea but in my case I'm getting time from logging.basicConfig(format='%(created)f %(message)s') and I'm not sure if I could use datetime.datetime.now() inside basicConfig. Second thing is that I have to verify that time delta is more than some value e.g. 2 sec or and datetime.timedelta object does not allow calculation. That's why I'm looking for value in milliseconds that could be obtained from logging using basicConfig()
    – susja
    Jan 25, 2015 at 19:47

0

You must log in to answer this question.

Browse other questions tagged .