log_helper_test_imported.py
1012 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"""
Dummy file that logs messages, meant to be imported
by the main test file
"""
from oletools.common.log_helper import log_helper
import warnings
DEBUG_MESSAGE = 'imported: debug log'
INFO_MESSAGE = 'imported: info log'
WARNING_MESSAGE = 'imported: warning log'
ERROR_MESSAGE = 'imported: error log'
CRITICAL_MESSAGE = 'imported: critical log'
RESULT_MESSAGE = 'imported: result log'
RESULT_TYPE = 'imported: result'
ACTUAL_WARNING = 'Feature XYZ provided by this module might be deprecated at '\
'some point in the future ... or not'
logger = log_helper.get_or_create_silent_logger('test_imported')
def enable_logging():
"""Enable logging if imported by third party modules."""
logger.setLevel(log_helper.NOTSET)
def log():
logger.debug(DEBUG_MESSAGE)
logger.info(INFO_MESSAGE)
logger.warning(WARNING_MESSAGE)
logger.error(ERROR_MESSAGE)
logger.critical(CRITICAL_MESSAGE)
logger.info(RESULT_MESSAGE, type=RESULT_TYPE)
def warn():
warnings.warn(ACTUAL_WARNING)