-
Notifications
You must be signed in to change notification settings - Fork 0
/
loglevels.py
34 lines (28 loc) · 1004 Bytes
/
loglevels.py
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
from loguru import logger
import sys
class SetLevel():
"""Set the levels for operations
"""
def __init__(self, level:str):
"""LOGURU initialization for set levels
Args:
level (str): what levels?
"""
self.level = level.upper()
if self.validateLogLevel():
self.setLevel()
def setLevel(self):
"""Set the levels
"""
logger.remove() #removes configuration for the default handler "0" is the default ID number
logger.add(sys.stderr, level=self.level) #only records logs with a severity of Warning and greater
def validateLogLevel(self, correct:bool=True) -> bool:
"""Validate the logs
Args:
correct (bool, optional): yes valid. Defaults to True.
Returns:
bool: correct?
"""
if self.level not in ["DEBUG", "TRACE", "INFO", "SUCCESS", "WARNING", "ERROR", "CRITICAL"]:
correct = False
return correct