-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlog.py
46 lines (32 loc) · 1.16 KB
/
log.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import logging, inspect
from logging.config import dictConfig
LOGGER_NAME: str = "default"
def set_up_logger(log_config: dict) -> None:
"""Set up the logger."""
dictConfig(log_config)
logger = logging.getLogger(LOGGER_NAME)
logger.info("Logger, Status: Ready ")
return None
def get_logger() -> logging.Logger:
"""Get the logger."""
return logging.getLogger(LOGGER_NAME)
def info(msg: str) -> None:
"""Log an info message."""
function_before: str = inspect.stack()[1].function
msg = f"function: {function_before} | {msg}"
get_logger().info(msg)
def debug(msg: str) -> None:
"""Log a debug message."""
function_before: str = inspect.stack()[1].function
msg = f"function: {function_before} | {msg}"
get_logger().debug(msg)
def warning(msg: str) -> None:
"""Log a warning message."""
function_before: str = inspect.stack()[1].function
msg = f"function: {function_before} | {msg}"
get_logger().warning(msg)
def error(msg: str) -> None:
"""Log an error message."""
function_before: str = inspect.stack()[1].function
msg = f"function: {function_before} | {msg}"
get_logger().error(msg)