19 lines
597 B
Python
19 lines
597 B
Python
"""공통 로깅 설정 — KST(Asia/Seoul) 타임존 포매터 제공."""
|
|
|
|
import logging
|
|
import datetime
|
|
import pytz
|
|
|
|
KST = pytz.timezone("Asia/Seoul")
|
|
|
|
|
|
class KSTFormatter(logging.Formatter):
|
|
"""%(asctime)s 를 KST(UTC+9) 기준으로 출력하는 포매터."""
|
|
|
|
def formatTime(self, record: logging.LogRecord, datefmt: str | None = None) -> str:
|
|
ct = datetime.datetime.fromtimestamp(record.created, tz=KST)
|
|
if datefmt:
|
|
return ct.strftime(datefmt)
|
|
t = ct.strftime(self.default_time_format)
|
|
return self.default_msec_format % (t, record.msecs)
|