i using python's logging module logs, needed timestamp include microsecond. seems timestamp can precise millisecond. here's test code
import logging logging.basicconfig(format='%(asctime)s %(levelname)s {%(module)s} [%(funcname)s] %(message)s', datefmt='%y-%m-%d,%h:%m:%s:%f', level=logging.info) class log2_test(): def test_class(self): logging.warning("warning2 inside class") def get_started2(): logging.info("logged2 here") if __name__ == '__main__': get_started2() here's output --
2015-07-09,16:36:37:f info {logger} [get_started2] logged2 here somehow, %f not recognized. python version 2.7.6.
how timestamp include microseconds? in advance.
i not think strftime() support %f directly. logger though provide milliseconds separate msecs attribute, add after existing timestamp follows:
logging.basicconfig(format='%(asctime)s.%(msecs)03d %(levelname)s {%(module)s} [%(funcname)s] %(message)s', datefmt='%y-%m-%d,%h:%m:%s', level=logging.info) this gave me following output using script:
2015-07-10,09:21:16.841 info {test script} [get_started2] logged2 here
Comments
Post a Comment