Cope 2.5.0
My personal "standard library" of all the generally useful code I've written for various projects over the years
Loading...
Searching...
No Matches
logging.py
1# from .colors import LOG_COLOR, coloredOutput, WARN
2from ..debugging import print_context
3from enum import Enum
4from ._config import config
5
6# TODO: rewrite these to use logging instead
7
8class LogLevel(Enum):
9 NONE = 0
10 LOGGING = 1
11 WARNINGS = 2
12 ERRORS = 3
13
14def log(message, levelReq=LogLevel.LOGGING):
15 if not __debug__: return
16 if config.verbosity >= levelReq.value:
17 print_context(2)
18 print(message, style='log')
19
20def warn(message):
21 if not __debug__: return
22 log(message, color=WARN)
23warning = warn
24
25def unreachableState(message=''):
26 if not __debug__: return
27 if len(message):
28 warn(f'Unreachable State Reached: {message}')
29 else:
30 warn('Unreachable State Reached!')
31unreachable = unreachableState