mirror of
https://github.com/Garmelon/PFERD.git
synced 2023-12-21 10:23:01 +01:00
Make logging easier
This commit is contained in:
parent
5e9ecd3ce1
commit
9693e1d968
@ -1,12 +1,35 @@
|
|||||||
|
import logging
|
||||||
|
|
||||||
from .ffm import *
|
from .ffm import *
|
||||||
from .ilias import *
|
from .ilias import *
|
||||||
from .norbert import *
|
from .norbert import *
|
||||||
from .utils import *
|
from .utils import *
|
||||||
|
|
||||||
__all__ = []
|
__all__ = ["STYLE", "FORMAT", "DATE_FORMAT", "FORMATTER", "enable_logging"]
|
||||||
|
|
||||||
__all__ += ffm.__all__
|
__all__ += ffm.__all__
|
||||||
__all__ += ilias.__all__
|
__all__ += ilias.__all__
|
||||||
__all__ += norbert.__all__
|
__all__ += norbert.__all__
|
||||||
__all__ += utils.__all__
|
__all__ += utils.__all__
|
||||||
|
|
||||||
LOG_FORMAT = "[%(levelname)s] %(message)s"
|
STYLE = "{"
|
||||||
|
FORMAT = "[{levelname:<7}] {message}"
|
||||||
|
DATE_FORMAT = "%F %T"
|
||||||
|
|
||||||
|
FORMATTER = logging.Formatter(
|
||||||
|
fmt=FORMAT,
|
||||||
|
datefmt=DATE_FORMAT,
|
||||||
|
style=STYLE,
|
||||||
|
)
|
||||||
|
|
||||||
|
def enable_logging(name="PFERD", level=logging.INFO):
|
||||||
|
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
|
||||||
|
Loading…
Reference in New Issue
Block a user