Skip to content

Commit c617f4d

Browse files
feat: Allow passing enableLog flag when creating SyncedEnforcer with adapter (#510)
1 parent 6504a9e commit c617f4d

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

src/main/java/org/casbin/jcasbin/main/Enforcer.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,18 @@ public Enforcer(String modelPath, String policyFile) {
5454
* @param adapter the adapter.
5555
*/
5656
public Enforcer(String modelPath, Adapter adapter) {
57-
this(newModel(modelPath, ""), adapter);
57+
this(modelPath, adapter, true);
58+
}
59+
60+
/**
61+
* Enforcer initializes an enforcer with a database adapter and an enable log flag.
62+
*
63+
* @param modelPath the path of the model file.
64+
* @param adapter the adapter.
65+
* @param enableLog whether to enable Casbin's log.
66+
*/
67+
public Enforcer(String modelPath, Adapter adapter, boolean enableLog) {
68+
this(newModel(modelPath, ""), adapter, enableLog);
5869
this.modelPath = modelPath;
5970
}
6071

src/main/java/org/casbin/jcasbin/main/SyncedEnforcer.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,17 @@ public SyncedEnforcer(String modelPath, Adapter adapter) {
7878
super(modelPath, adapter);
7979
}
8080

81+
/**
82+
* SyncedEnforcer initializes an enforcer with a database adapter and an enable log flag.
83+
*
84+
* @param modelPath the path of the model file.
85+
* @param adapter the adapter.
86+
* @param enableLog whether to enable Casbin's log.
87+
*/
88+
public SyncedEnforcer(String modelPath, Adapter adapter, boolean enableLog) {
89+
super(modelPath, adapter, enableLog);
90+
}
91+
8192
/**
8293
* SyncedEnforcer initializes an enforcer with a model and a database adapter.
8394
*
@@ -88,6 +99,17 @@ public SyncedEnforcer(Model m, Adapter adapter) {
8899
super(m, adapter);
89100
}
90101

102+
/**
103+
* SyncedEnforcer initializes an enforcer with a model, a database adapter and an enable log flag.
104+
*
105+
* @param m the model.
106+
* @param adapter the adapter.
107+
* @param enableLog whether to enable Casbin's log.
108+
*/
109+
public SyncedEnforcer(Model m, Adapter adapter, boolean enableLog) {
110+
super(m, adapter, enableLog);
111+
}
112+
91113
/**
92114
* SyncedEnforcer initializes an enforcer with a model.
93115
*

0 commit comments

Comments
 (0)