created logging initializer
This commit is contained in:
parent
72dee6dac7
commit
3cd6c5ed12
|
|
@ -1 +1,20 @@
|
|||
# Dedicated module for defining and interpreting errors as well as generating error messages
|
||||
|
||||
import logging
|
||||
|
||||
|
||||
logging.basicConfig(encoding='utf-8', level=logging.DEBUG)
|
||||
|
||||
|
||||
def initlogging(filename=None, loglevel="ERROR"):
|
||||
"""
|
||||
Initializes logging
|
||||
"""
|
||||
loglevel = loglevel.upper()
|
||||
if loglevel not in ["ERROR", "INFO", "WARNING", "DEBUG", "CRITICAL"]:
|
||||
print("Incorrect logging", loglevel + ". Defaulting to ERROR.")
|
||||
loglevel = "ERROR"
|
||||
logging.basicConfig(encoding="utf-8")
|
||||
if filename is not None:
|
||||
logging.basicConfig(filename=filename)
|
||||
logging.basicConfig(level=logging.__getattribute__(loglevel))
|
||||
|
|
|
|||
Loading…
Reference in New Issue