nos0s/groundwork/log.py

42 lines
692 B
Python
Raw Normal View History

2023-03-21 21:52:27 +00:00
class LogLevel:
DEBUG = 0
WARNING = 1
ERROR = 2
CRITICAL = 3
log_lvl = LogLevel.CRITICAL
def set_lvl(lvl):
global log_lvl
if lvl < LogLevel.DEBUG:
lvl = LogLevel.DEBUG
if lvl > LogLevel.CRITICAL:
lvl = LogLevel.CRITICAL
log_lvl = lvl
def debug(message):
global log_lvl
if log_lvl <= LogLevel.DEBUG:
print(message)
def warning(message):
global log_lvl
if log_lvl <= LogLevel.WARNING:
print(message)
def error(message):
global log_lvl
if log_lvl <= LogLevel.ERROR:
print(message)
def critical(message):
global log_lvl
if log_lvl <= LogLevel.CRITICAL:
print(message)