15 Test if the log summary is shown correctly in all cases
18 from basf2
import create_path, process, Module, logging, LogLevel, LogInfo, \
19 B2WARNING, B2FATAL, B2ERROR
20 import multiprocessing
23 def fork_process(*args, target=process):
24 """Run function in forked child to eliminate side effects"""
25 sub = multiprocessing.Process(target=target, args=args)
30 class FatalError(Module):
31 """Simple module to just print a warning, an error and a fatal error"""
37 B2FATAL(
"fatal error")
40 logging.log_level = LogLevel.WARNING
41 for level
in LogLevel.values.values():
42 logging.set_info(level, LogInfo.LEVEL | LogInfo.MODULE | LogInfo.PACKAGE | LogInfo.MESSAGE)
45 main.add_module(
"EventInfoSetter")
46 module = main.add_module(FatalError())
48 print(
"run in default settings")
51 print(
"run with no warnings")
52 logging.log_level = LogLevel.ERROR
54 logging.log_level = LogLevel.WARNING
56 print(
"run with no framework warnings")
57 logging.package(
"framework").log_level = LogLevel.ERROR
59 logging.package(
"framework").log_level = LogLevel.WARNING
61 print(
"run with no module warnings")
62 module.set_log_level(LogLevel.ERROR)
64 module.set_log_level(LogLevel.WARNING)
66 print(
"run without summary")
67 logging.enable_summary(
False)