Difficult-Rocket/libs/utils/logger/formatter.py

26 lines
618 B
Python
Raw Normal View History

2023-10-14 15:36:43 +08:00
# -------------------------------
# Difficult Rocket
# Copyright © 2020-2023 by shenjackyuanjie 3695888@qq.com
# All rights reserved
# -------------------------------
import time
from lib_not_dr.types.options import Options
from .types import LogMessage
class BaseFormatter(Options):
name = 'BaseFormatter'
def format(self, message: LogMessage) -> str:
raise NotImplementedError(f'{self.__class__.__name__}.format is not implemented')
class TimeFormatter(BaseFormatter):
name = 'TimeFormatter'
def format(self, message: LogMessage) -> str:
return f'[{message.log_time}]'