nos0s/common/log.py

42 lines
692 B
Python

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)