2019-04-25 21:41:26 +02:00
|
|
|
import logging
|
|
|
|
|
2020-04-20 12:08:52 +02:00
|
|
|
# from .ilias import *
|
|
|
|
# from .utils import *
|
|
|
|
from .temp_folder import *
|
2018-11-20 06:55:41 +01:00
|
|
|
|
2019-04-25 21:41:26 +02:00
|
|
|
STYLE = "{"
|
|
|
|
FORMAT = "[{levelname:<7}] {message}"
|
|
|
|
DATE_FORMAT = "%F %T"
|
|
|
|
|
|
|
|
FORMATTER = logging.Formatter(
|
2020-04-20 12:08:52 +02:00
|
|
|
fmt=FORMAT,
|
|
|
|
datefmt=DATE_FORMAT,
|
|
|
|
style=STYLE,
|
2019-04-25 21:41:26 +02:00
|
|
|
)
|
|
|
|
|
2020-04-20 12:08:52 +02:00
|
|
|
|
2020-04-20 03:54:47 +02:00
|
|
|
def enable_logging(name: str = "PFERD", level: int = logging.INFO) -> None:
|
2019-04-25 21:41:26 +02:00
|
|
|
handler = logging.StreamHandler()
|
|
|
|
handler.setFormatter(FORMATTER)
|
|
|
|
|
|
|
|
logger = logging.getLogger(name)
|
|
|
|
logger.setLevel(level)
|
|
|
|
logger.addHandler(handler)
|
|
|
|
|
|
|
|
# This should be logged by our own handler, and not the root logger's
|
|
|
|
# default handler, so we don't pass it on to the root logger.
|
|
|
|
logger.propagate = False
|