Skip to content

Commit

Permalink
fix: disabled all logger (#324)
Browse files Browse the repository at this point in the history
* fix: disabled all logger

* fix: disabled all logger

Co-authored-by: AurelienGAB <[email protected]>

* tests: fix disabled logger

---------

Co-authored-by: AurelienGAB <[email protected]>
  • Loading branch information
Rémi Germain and AurelienGAB authored Sep 30, 2023
1 parent bbab273 commit ae81a52
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions casbin/core_enforcer.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from casbin.persist.adapters import FileAdapter
from casbin.rbac import default_role_manager
from casbin.util import generate_g_function, SimpleEval, util, generate_conditional_g_function
from casbin.util.log import configure_logging
from casbin.util.log import configure_logging, disabled_logging


class EnforceContext:
Expand Down Expand Up @@ -71,7 +71,7 @@ def __init__(self, model=None, adapter=None, enable_log=False):
if enable_log:
configure_logging()
else:
logging.disable(logging.CRITICAL)
disabled_logging()

def init_with_file(self, model_path, policy_path):
"""initializes an enforcer with a model file and a policy file."""
Expand Down
5 changes: 5 additions & 0 deletions casbin/util/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,8 @@ def configure_logging(logging_config=None):
logging.config.dictConfig(logging_config)
else:
logging.config.dictConfig(DEFAULT_LOGGING)


def disabled_logging():
for logger_name in DEFAULT_LOGGING["loggers"].keys():
logging.getLogger(logger_name).disabled = True

0 comments on commit ae81a52

Please sign in to comment.