2 Global logging utilities for initialization.
9 """"! setup and configure the logging using the HPSMC block of the passed config
11 The parameters 'loglevel' and 'logfile' are checked within the 'HPSMC' block of the config.
12 The default loglevel is INFO and the default logfile is the terminal (stdout).
14 loglevel = logging.INFO
15 logstream = sys.stdout
20 if 'loglevel' in config[
'HPSMC']:
21 loglevel = logging.getLevelName(config[
'HPSMC'][
'loglevel'])
24 if 'logfile' in config[
'HPSMC']:
25 logstream = open(config[
'HPSMC'][
'logfile'],
'w')
29 logger = logging.getLogger(
"hpsmc")
30 logger.propagate =
False
32 logger.setLevel(loglevel)
33 handler = logging.StreamHandler(logstream)
34 handler.setLevel(logging.DEBUG)
35 handler.setFormatter(logging.Formatter(
'%(name)s:%(levelname)s %(message)s'))
36 logger.addHandler(handler)
def _setup_logging(config)