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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

logger print exception #327

Open
gensir opened this issue Sep 30, 2021 · 5 comments
Open

logger print exception #327

gensir opened this issue Sep 30, 2021 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@gensir
Copy link

gensir commented Sep 30, 2021

Hi! 馃憢

Firstly, thanks for your work on this project! 馃檪

Today I used patch-package to patch casbin@5.11.5 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/casbin/lib/cjs/coreEnforcer.js b/node_modules/casbin/lib/cjs/coreEnforcer.js
index b9e4f06..9e9ff26 100644
--- a/node_modules/casbin/lib/cjs/coreEnforcer.js
+++ b/node_modules/casbin/lib/cjs/coreEnforcer.js
@@ -158,6 +158,7 @@ class CoreEnforcer {
     async loadPolicy() {
         this.model.clearPolicy();
         await this.adapter.loadPolicy(this.model);
+        this.model.printPolicy();
         this.sortPolicies();
         if (this.autoBuildRoleLinks) {
             await this.buildRoleLinksInternal();
diff --git a/node_modules/casbin/lib/cjs/rbac/defaultRoleManager.js b/node_modules/casbin/lib/cjs/rbac/defaultRoleManager.js
index 1db1411..c3a25db 100644
--- a/node_modules/casbin/lib/cjs/rbac/defaultRoleManager.js
+++ b/node_modules/casbin/lib/cjs/rbac/defaultRoleManager.js
@@ -285,8 +285,10 @@ class DefaultRoleManager {
      */
     async printRoles() {
         if (log_1.getLogger().isEnable()) {
-            [...this.allDomains.values()].forEach((n) => {
-                log_1.logPrint(n.toString());
+            [...this.allDomains.values()].forEach((roles) => {
+                roles.forEach(n => { 
+                    log_1.logPrint(n.toString());
+                });
             });
         }
     }

This issue body was partially generated by patch-package.

@casbin-bot
Copy link
Member

@casbin-bot casbin-bot added the question Further information is requested label Sep 30, 2021
@hsluoyz hsluoyz added bug Something isn't working and removed question Further information is requested labels Oct 1, 2021
@nodece
Copy link
Member

nodece commented Oct 2, 2021

Do you want to print the policy data?

@gensir
Copy link
Author

gensir commented Oct 9, 2021

async printRoles() {
      if (log_1.getLogger().isEnable()) {
          [...this.allDomains.values()].forEach((roles) => {
              console.log(roles);// Roles(0) [Map] {}
              roles.forEach(n => { 
                  log_1.logPrint(n.toString());
              });
          });
      }
  }

@hsluoyz
Copy link
Member

hsluoyz commented Oct 9, 2021

@gensir plz make a PR!

@gensir
Copy link
Author

gensir commented Oct 29, 2021

#330

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Development

Successfully merging a pull request may close this issue.

4 participants