File: logger.py

package info (click to toggle)
zigpy-znp 0.14.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,112 kB
  • sloc: python: 14,241; makefile: 6
file content (23 lines) | stat: -rw-r--r-- 710 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import logging

LOGGER = logging.getLogger(__name__)
_TRACE = 5


def _find_trace_level() -> int:
    if logging.getLevelName(_TRACE) != f"Level {_TRACE}":
        # If a level 5 exists, use it
        return _TRACE
    elif hasattr(logging, "TRACE") and logging.NOTSET < logging.TRACE < logging.DEBUG:
        # If a valid TRACE level exists that is between 0 and 10, use it
        return logging.TRACE
    elif LOGGER.level == logging.DEBUG:
        # If `zigpy_znp.logger` is explicitly passed `DEBUG` as a log level, enable
        # `TRACE` logging under the `DEBUG` level
        return logging.DEBUG
    else:
        # Otherwise, do not log
        return logging.NOTSET


TRACE = _find_trace_level()