mirror of
https://github.com/status-im/status-python-sdk.git
synced 2026-08-30 21:51:14 +00:00
25 lines
672 B
Python
25 lines
672 B
Python
from typing import Optional
|
|
import logging
|
|
|
|
class Logger:
|
|
instance: Optional[logging.Logger] = None
|
|
|
|
def __new__(cls, name: str = "status-bot") -> logging.Logger:
|
|
|
|
if cls.instance:
|
|
return logging.getLogger(name)
|
|
|
|
cls.instance = logging.getLogger(name)
|
|
cls.instance.setLevel(logging.INFO)
|
|
cls.instance.propagate = False
|
|
|
|
handler = logging.StreamHandler()
|
|
formatter = logging.Formatter(
|
|
f"[%(asctime)s] [%(levelname)s]\t%(message)s",
|
|
datefmt="%Y-%m-%d %H:%M:%S"
|
|
)
|
|
|
|
handler.setFormatter(formatter)
|
|
cls.instance.addHandler(handler)
|
|
return cls.instance
|