Coverage for local_installation/dynasor/logging_tools.py: 100%
10 statements
« prev ^ index » next coverage.py v7.3.2, created at 2024-12-21 12:02 +0000
« prev ^ index » next coverage.py v7.3.2, created at 2024-12-21 12:02 +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(
23 r'%(levelname)s %(asctime)s: %(message)s', datefmt='%Y-%m-%d %H:%M:%S'))
24logger.addHandler(ch)
27def set_logging_level(level):
28 """
29 Alters the logging verbosity logging is handled.
31 level Numeric value
33 * CRITICAL 50
34 * ERROR 40
35 * WARNING 30
36 * INFO 20
37 * DEBUG 10
38 * NOTSET 0
40 Parameters
41 ----------
42 level : int
43 verbosity level; see `Python logging library
44 <https://docs.python.org/3/library/logging.html>`_ for details
45 """
46 logger.setLevel(level)