I just found the following solution:
import logging class UnixTimeStampFormatter(logging.Formatter): def formatTime(self, record, datefmt = None): return "{0:.6f}".format(record.created) def main(): logChannel = logging.StreamHandler() logChannel.setFormatter(UnixTimeStampFormatter("%(asctime)s %(levelname)-5.5s [%(name)s] %(message)s")) logging.getLogger().setLevel(logging.DEBUG) logging.getLogger().addHandler(logChannel) logging.debug('hello'); if __name__ == "__main__": main()
source share