Skip to content

Commit

Permalink
rename skip_log to setup_log
Browse files Browse the repository at this point in the history
  • Loading branch information
byjg committed Nov 16, 2024
1 parent 06ea2bb commit 6df8e39
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions src/functions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -426,7 +426,7 @@ def find_missing_certificates(self, hosts):
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)
12 changes: 6 additions & 6 deletions src/tests/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@
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']


Expand Down

0 comments on commit 6df8e39

Please sign in to comment.