mirror of
https://github.com/status-im/status-python-sdk.git
synced 2026-08-30 21:51:14 +00:00
Related to https://github.com/status-im/status-bot/issues/7 - Add custom logger to `Account` class - Add `display_name` validation based on Status App - Update new `display_name` for other accounts when account has been recovered with mnemonics - Update documentation
25 lines
643 B
Python
25 lines
643 B
Python
from typing import Optional
|
|
import logging
|
|
|
|
class Logger:
|
|
instance: Optional[logging.Logger] = None
|
|
|
|
def __new__(cls) -> logging.Logger:
|
|
|
|
if cls.instance:
|
|
return cls.instance
|
|
|
|
cls.instance = logging.getLogger("status-bot")
|
|
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
|