Enhance | logger with Template
This commit is contained in:
parent
1cfd6cc066
commit
79cdba7b9c
@ -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}]'
|
||||
|
Loading…
Reference in New Issue
Block a user