15from basf2
import Path, process, logging, set_log_level, set_debug_level, \
16 LogConfig, LogLevel, LogInfo, B2DEBUG, B2INFO, B2WARNING
19print(
'Default loglevel:', logging.log_level)
22logging.log_level = LogLevel.DEBUG
24set_log_level(LogLevel.DEBUG)
25print(
'New loglevel: ', logging.log_level)
28logging.debug_level = 123
34pxd_logging = LogConfig(LogLevel.WARNING, 0)
35pxd_logging.abort_level = LogLevel.ERROR
36logging.set_package(
'pxd', pxd_logging)
40logging.package(
'svd').debug_level = 10
41logging.package(
'svd').set_info(LogLevel.INFO, LogInfo.LEVEL | LogInfo.MESSAGE |
45for (name, value)
in LogLevel.names.items():
47 print(f
'LogInfo for level {name:8}: {logging.get_info(value):3}')
52logging.add_file(
'test.log')
54logging.add_console(
True)
58B2DEBUG(100,
'Debug Message')
60B2WARNING(
'Warning Message')
67 B2DEBUG(100,
'A repeated message!')
69B2INFO(
'Some other message')
76for (level, num)
in logging.log_stats.items():
77 print(f
'Messages for level {level.name:8}: {num:2}')
80eventinfosetter = main.add_module(
'EventInfoSetter')
83eventinfosetter.logging.log_level = LogLevel.ERROR
84eventinfosetter.logging.set_info(LogLevel.ERROR, LogInfo.FILE | LogInfo.LINE)
86eventinfosetter.set_log_level(LogLevel.ERROR)
87eventinfosetter.set_log_info(LogLevel.ERROR, LogInfo.FILE | LogInfo.LINE)
90currentInfo = logging.get_info(LogLevel.INFO)
91logging.set_info(LogLevel.INFO, currentInfo | LogInfo.TIMESTAMP)
94set_log_level(LogLevel.INFO)
95eventinfosetter.param(
'evtNumList', [30])
96main.add_module(
'EventInfoPrinter', logLevel=LogLevel.DEBUG)