emdbg.logger

 1# Copyright (c) 2023, Auterion AG
 2# SPDX-License-Identifier: BSD-3-Clause
 3
 4import logging
 5import logging.config
 6
 7VERBOSITY = 0
 8LEVEL = logging.WARNING
 9
10
11def configure(verbosity: int = None):
12    """
13    Configures the logging of the entire module.
14
15    :param verbosity:
16        Set the logging level: ≥-1: ERROR, ≥0: WARNING, ≥1: INFO, ≥2: DEBUG.
17        Default is None=0=WARNING.
18    """
19    if verbosity is None:
20        verbosity = 0
21
22    global VERBOSITY
23    VERBOSITY = verbosity
24
25    global LEVEL
26    if verbosity >= 2:
27        LEVEL = logging.DEBUG
28    elif verbosity == 1:
29        LEVEL = logging.INFO
30    elif verbosity == 0:
31        LEVEL = logging.WARNING
32    else:
33        LEVEL = logging.ERROR
34
35    # TODO: Custom logger configuration for only the emdbg module
36    logging.basicConfig(level=LEVEL)
37
38    # Disable some particularly chatty modules
39    logging.getLogger("pygdbmi.IoManager").setLevel(logging.INFO)
40    logging.getLogger("graphviz._tools").setLevel(logging.INFO)
VERBOSITY = 0
LEVEL = 30
def configure(verbosity: int = None):
12def configure(verbosity: int = None):
13    """
14    Configures the logging of the entire module.
15
16    :param verbosity:
17        Set the logging level: ≥-1: ERROR, ≥0: WARNING, ≥1: INFO, ≥2: DEBUG.
18        Default is None=0=WARNING.
19    """
20    if verbosity is None:
21        verbosity = 0
22
23    global VERBOSITY
24    VERBOSITY = verbosity
25
26    global LEVEL
27    if verbosity >= 2:
28        LEVEL = logging.DEBUG
29    elif verbosity == 1:
30        LEVEL = logging.INFO
31    elif verbosity == 0:
32        LEVEL = logging.WARNING
33    else:
34        LEVEL = logging.ERROR
35
36    # TODO: Custom logger configuration for only the emdbg module
37    logging.basicConfig(level=LEVEL)
38
39    # Disable some particularly chatty modules
40    logging.getLogger("pygdbmi.IoManager").setLevel(logging.INFO)
41    logging.getLogger("graphviz._tools").setLevel(logging.INFO)

Configures the logging of the entire module.

Parameters
  • verbosity: Set the logging level: ≥-1: ERROR, ≥0: WARNING, ≥1: INFO, ≥2: DEBUG. Default is None=0=WARNING.