blob: 2998756a27e4f99a52b6eb7d10d6de48cf75afae (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
"""Custom formatters for the logging handlers."""
import logging
import time
class TimestampFormatter(logging.Formatter):
"""Timestamp formatter for log messages.
Timestamp format example: 13:27:03.246Z
"""
def formatTime(self, record, datefmt=None):
"""Return formatted time."""
converted_time = self.converter(record.created)
if datefmt is not None:
return time.strftime(datefmt, converted_time)
formatted_time = time.strftime("%H:%M:%S", converted_time)
return "%s.%03dZ" % (formatted_time, record.msecs)
|