Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: disabled all logger #324

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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