MCPcopy Create free account
hub / github.com/PaddlePaddle/FastDeploy / CSTFormatter

Class CSTFormatter

tests/ce/server/core/logger.py:43–58  ·  view source on GitHub ↗

自定义时间格式化器,指定时区为东八区

Source from the content-addressed store, hash-verified

41
42 # 自定义时间格式化器,指定时区为东八区
43 class CSTFormatter(logging.Formatter):
44 """
45 自定义时间格式化器,指定时区为东八区
46 """
47
48 def converter(self, timestamp):
49 """
50 自定义时间转换函数,加上时区信息
51 Args:
52 timestamp (int): 时间戳。
53 Returns:
54 tuple: 格式化后的时间元组。
55 """
56 dt = datetime.utcfromtimestamp(timestamp)
57 dt = pytz.utc.localize(dt).astimezone(tz)
58 return dt.timetuple()
59
60 formatter = CSTFormatter(self.LOG_FORMAT)
61 log_name = None

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected