Révision bf33f563 modules/config_log.py
b/modules/config_log.py | ||
---|---|---|
1 | 1 |
"""Configures the logger to record all calculation events on a log file.""" |
2 | 2 |
import sys |
3 | 3 |
import logging |
4 |
import warnings |
|
4 | 5 |
|
5 | 6 |
|
6 | 7 |
def log_exception(exc_type, exc_value, exc_tb): |
... | ... | |
11 | 12 |
logger.error("", exc_info=(exc_type, exc_value, exc_tb)) |
12 | 13 |
|
13 | 14 |
|
14 |
def config_log(label): # TODO Format log to break line after column 80. |
|
15 |
logging.captureWarnings(True) |
|
16 |
warnings_logger = logging.getLogger("py.warnings") |
|
15 |
def log_warning(message, *args, **kwargs): |
|
16 |
logger = logging.getLogger('DockOnSurf') |
|
17 |
logger.warning(" ".join(f"{message}".split())) |
|
18 |
|
|
17 | 19 |
|
20 |
def config_log(label): # TODO Format log to break line after column 80. |
|
18 | 21 |
logger = logging.getLogger(label) |
19 | 22 |
logger.setLevel(logging.INFO) |
20 | 23 |
|
... | ... | |
25 | 28 |
log_handler.setFormatter(log_format) |
26 | 29 |
|
27 | 30 |
logger.addHandler(log_handler) |
28 |
warnings_logger.addHandler(log_handler) |
|
31 |
|
|
29 | 32 |
sys.excepthook = log_exception |
33 |
warnings.showwarning = log_warning |
|
30 | 34 |
|
31 | 35 |
return logger |
Formats disponibles : Unified diff