Coverage for local_installation/dynasor/logging_tools.py: 100%
10 statements
« prev ^ index » next coverage.py v7.3.2, created at 2023-11-30 21:04 +0000
« prev ^ index » next coverage.py v7.3.2, created at 2023-11-30 21:04 +0000
1""" This module contains functions and variables to control dynasor's logging
3* `logger` - the module logger
4"""
6import logging
7import sys
10# This is the root logger of dynasor
11logger = logging.getLogger('dynasor')
13# Will process all levels of INFO or higher
14logger.setLevel(logging.INFO)
16# If you know what you are doing you may set this to True
17logger.propagate = False
19# The dynasor logger will collect events from childs and the default behaviour
20# is to print it directly to stdout
21ch = logging.StreamHandler(sys.stdout)
22ch.setFormatter(logging.Formatter(r'%(levelname)s: %(message)s'))
23logger.addHandler(ch)
26def set_logging_level(level):
27 """
28 Alters the logging verbosity logging is handled.
30 level Numeric value
32 * CRITICAL 50
33 * ERROR 40
34 * WARNING 30
35 * INFO 20
36 * DEBUG 10
37 * NOTSET 0
39 Parameters
40 ----------
41 level : int
42 verbosity level; see `Python logging library
43 <https://docs.python.org/3/library/logging.html>`_ for details
44 """
45 logger.setLevel(level)