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