This repository has been archived on 2024-07-30. You can view files and clone it, but cannot push or open issues or pull requests.
python-aternos/python_aternos/atlog.py

32 lines
579 B
Python
Raw Normal View History

"""Creates a logger"""
import logging
log = logging.getLogger('aternos')
handler = logging.StreamHandler()
2023-07-04 14:47:22 +04:00
fmt = logging.Formatter('%(asctime)s %(levelname)-5s %(message)s')
handler.setFormatter(fmt)
log.addHandler(handler)
def is_debug() -> bool:
"""Is debug logging enabled"""
return log.level == logging.DEBUG
def set_debug(state: bool) -> None:
"""Enable debug logging"""
if state:
set_level(logging.DEBUG)
else:
set_level(logging.WARNING)
def set_level(level: int) -> None:
log.setLevel(level)
handler.setLevel(level)