1
2
3
4 """
5 `sword2` logging
6 """
7
8 import logging
9 import logging.config
10 from os import path as os_path
11
12 SWORD2_LOGGING_CONFIG = "./sword2_logging.conf"
13
14 BASIC_CONFIG = """[loggers]
15 keys=root
16
17 [handlers]
18 keys=consoleHandler
19
20 [formatters]
21 keys=basicFormatting
22
23 [logger_root]
24 level=INFO
25 handlers=consoleHandler
26
27 [handler_consoleHandler]
28 class=StreamHandler
29 level=DEBUG
30 formatter=basicFormatting
31 args=(sys.stdout,)
32
33 [formatter_basicFormatting]
34 format=%(asctime)s - %(name)s - %(levelname)s - %(message)s
35 """
36
38 fn = open(pathtologgingconf, "w")
39 fn.write(BASIC_CONFIG)
40 fn.close()
41
42 if not os_path.isfile(SWORD2_LOGGING_CONFIG):
43 create_logging_config(SWORD2_LOGGING_CONFIG)
44
45 logging.config.fileConfig(SWORD2_LOGGING_CONFIG)
46