1
0
Fork 0

rename skip_log to setup_log

This commit is contained in:
Joao Gilberto Magalhaes 2024-11-16 10:49:46 -06:00
parent 06ea2bbd3f
commit 6df8e39bb1
2 changed files with 11 additions and 11 deletions

View file

@ -104,7 +104,7 @@ class Functions:
FATAL = "FATAL"
@staticmethod
def skip_log(source, log_level_str):
def setup_log(source):
level = os.getenv("%s_LOG_LEVEL" % (source.name.upper()), "").upper()
level_importance = {
Functions.TRACE: logging.DEBUG,
@ -426,7 +426,7 @@ loggerInit = logging.getLogger(Functions.INIT_LOG)
loggerHaproxy = logging.getLogger(Functions.HAPROXY_LOG)
loggerEasyHaproxy = logging.getLogger(Functions.EASYHAPROXY_LOG)
loggerCertbot = logging.getLogger(Functions.CERTBOT_LOG)
Functions.skip_log(loggerInit, Functions.INIT_LOG)
Functions.skip_log(loggerHaproxy, Functions.HAPROXY_LOG)
Functions.skip_log(loggerEasyHaproxy, Functions.EASYHAPROXY_LOG)
Functions.skip_log(loggerCertbot, Functions.CERTBOT_LOG)
Functions.setup_log(loggerInit)
Functions.setup_log(loggerHaproxy)
Functions.setup_log(loggerEasyHaproxy)
Functions.setup_log(loggerCertbot)

View file

@ -18,20 +18,20 @@ loggerDebug.setLevel(logging.DEBUG)
loggerDebug.addHandler(log_handler)
def test_functions_check_local_level():
assert Functions.skip_log(loggerCertbot, Functions.INFO) == logging.INFO
assert Functions.skip_log(loggerHaproxy, Functions.INFO) == logging.INFO
assert Functions.skip_log(loggerEasyHaproxy, Functions.INFO) == logging.INFO
assert Functions.setup_log(loggerCertbot) == logging.INFO
assert Functions.setup_log(loggerHaproxy) == logging.INFO
assert Functions.setup_log(loggerEasyHaproxy) == logging.INFO
os.environ['CERTBOT_LOG_LEVEL'] = 'warn'
assert Functions.skip_log(loggerCertbot, Functions.WARN) == logging.WARNING
assert Functions.setup_log(loggerCertbot) == logging.WARNING
del os.environ['CERTBOT_LOG_LEVEL']
os.environ['HAPROXY_LOG_LEVEL'] = 'warn'
assert Functions.skip_log(loggerHaproxy, Functions.INFO) == logging.WARNING
assert Functions.setup_log(loggerHaproxy) == logging.WARNING
del os.environ['HAPROXY_LOG_LEVEL']
os.environ['EASYHAPROXY_LOG_LEVEL'] = 'warn'
assert Functions.skip_log(loggerEasyHaproxy, Functions.INFO) == logging.WARNING
assert Functions.setup_log(loggerEasyHaproxy) == logging.WARNING
del os.environ['EASYHAPROXY_LOG_LEVEL']