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

Enforcer enable_log insanity #362

Open
mconigliaro opened this issue Dec 11, 2024 · 1 comment
Open

Enforcer enable_log insanity #362

mconigliaro opened this issue Dec 11, 2024 · 1 comment

Comments

@mconigliaro
Copy link

The enable_log parameter in Enforcer() makes it difficult to specify your own logging handlers. If you enable that option, your logs will get configured the way the casbin devs want them instead of the way you want them. If you leave that option disabled, they explicitly disable the casbin.enforcer logger for some reason, so those messages will never appear.

Solution:

  1. Leave enable_log disabled:

    enforcer = Enforcer("model.conf", "policy.csv")
  2. Re-enable the casbin.enforcer logger yourself:

    logging.getLogger("casbin.enforcer").disabled = False
  3. Now you can add your own logging handlers

    logging.getLogger("casbin.enforcer").addHandler(RichHandler())
    logging.getLogger("casbin.enforcer").setLevel(logging.INFO)
@hsluoyz
Copy link
Member

hsluoyz commented Dec 11, 2024

@mconigliaro can you make a PR to improve it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants