Enhance | logger with Template

This commit is contained in:
shenjack 2023-10-16 22:13:21 +08:00
parent 1cfd6cc066
commit 79cdba7b9c
Signed by: shenjack
GPG Key ID: 7B1134A979775551

View File

@ -6,6 +6,7 @@
import time
from string import Template
from typing import List
from lib_not_dr.types.options import Options
@ -51,11 +52,12 @@ class TimeFormatter(BaseFormatter):
name = 'TimeFormatter'
time_format: str = '%Y-%m-%d %H:%M:%S'
msec_time_format: str = '{}-{:03d}'
@classmethod
def _info(cls) -> str:
return cls.add_info('log_time', 'when the log message was created', 'The time format string'
'. See https://docs.python.org/3/library/time.html#time.strftime for more information.')
return cls.add_info('log_time', 'formatted time when logging', 'The time format string'
'. See https://docs.python.org/3/library/time.html#time.strftime for more information.')
def format(self, message: LogMessage) -> str:
return f'[{message.log_time}]'