Coverage for src/signal_edges/definitions.py: 67%
7 statements
« prev ^ index » next coverage.py v7.4.3, created at 2024-04-21 11:16 +0000
« prev ^ index » next coverage.py v7.4.3, created at 2024-04-21 11:16 +0000
1"""Common definitions for the package."""
3import logging
6def get_logger() -> logging.Logger:
7 """Retrieves the logger for the package, this logger can be configured externally like below:
9 .. code-block:: python
11 logger = logging.getLogger("python-signal-edges-logger")
13 # Configure logger...
15 # Mark as initialized.
16 setattr(logger, "init", True)
18 If the logger is not configured externally, the library uses a no-op logger by default. This
19 logger can be used by both the package and the user, and it is available in all the base
20 classes in this package for their derived classes to use.
22 :return: The logger."""
23 logger = logging.getLogger("python-signal-edges-logger")
25 # If not initialized, then initialize it to no-op logger.
26 if not hasattr(logger, "init"): 26 ↛ 28line 26 didn't jump to line 28, because the condition on line 26 was never true
27 # Set the output to the null handler.
28 logger.addHandler(logging.NullHandler())
29 # Initialize it.
30 setattr(logger, "init", True)
32 return logger