Révision 4e82c425 modules/config_log.py

b/modules/config_log.py
1
"""Configures the logger to record all calculation events on a log file."""
1
"""Module for the configuration of how and what is recorded in the log file."""
2 2
import sys
3 3
import logging
4 4
import warnings
5 5

  
6 6

  
7 7
def log_exception(exc_type, exc_value, exc_tb):
8
    """Sets up the recording of exceptions on the log file
9

  
10
    @param exc_type: Type of exception
11
    @param exc_value: Value of the exception
12
    @param exc_tb:
13
    @return: None
14
    """
8 15
    if issubclass(exc_type, KeyboardInterrupt):
9 16
        sys.__excepthook__(exc_type, exc_value, exc_tb)
10 17
        return
......
13 20

  
14 21

  
15 22
def log_warning(message, *args, **kwargs):
23
    """Sets up the recording of warnings on the log file
24

  
25
    @param message: Warning message.
26
    @param args: Additional arguments.
27
    @param kwargs: Additional keyword arguments.
28
    @return: None
29
    """
16 30
    logger = logging.getLogger('DockOnSurf')
17 31
    logger.warning(" ".join(f"{message}".split()))
18 32

  
19 33

  
20
def config_log(label):  # TODO Format log to break line after column 80.
34
def config_log(label):  # TODO Format log to break long lines (after column 80).
35
    """Configures the logger to record all calculation events on a log file.
36

  
37
    @param label: Label of the logger to be used.
38
    @return: The logger object.
39
    """
21 40
    logger = logging.getLogger(label)
22 41
    logger.setLevel(logging.INFO)
23 42

  

Formats disponibles : Unified diff