def get_logging_level(MESSAGELEVEL=None):
'''get_logging_level will return a logging level based on first
a variable going into the function, then an environment variable
MESSAGELEVEL, and then the default is DEBUG.
:param MESSAGELEVEL: the level to get.
'''
if MESSAGELEVEL == None:
MESSAGELEVEL = os.environ.get("MESSAGELEVEL","DEBUG")
if MESSAGELEVEL in ["DEBUG","INFO"]:
print("Environment message level found to be %s" %MESSAGELEVEL)
if MESSAGELEVEL == "FATAL":
return logging.FATAL
elif MESSAGELEVEL == "CRITICAL":
return logging.CRITICAL
elif MESSAGELEVEL == "ERROR":
return logging.ERROR
elif MESSAGELEVEL == "WARNING":
return logging.WARNING
elif MESSAGELEVEL == "INFO":
return logging.INFO
elif MESSAGELEVEL in "DEBUG":
return logging.DEBUG
return logging.DEBUG
评论列表
文章目录