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