+class MillisecondAwareFormatter(logging.Formatter):
+ converter = datetime.datetime.fromtimestamp
+
+ def formatTime(self, record, datefmt=None):
+ ct = self.converter(record.created, pytz.timezone("US/Pacific"))
+ if datefmt:
+ s = ct.strftime(datefmt)
+ else:
+ t = ct.strftime("%Y-%m-%d %H:%M:%S")
+ s = "%s,%03d" % (t, record.msecs)
+ return s
+
+