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

Turn off Log.Print #26

Closed
hengpor opened this issue Jun 19, 2017 · 2 comments
Closed

Turn off Log.Print #26

hengpor opened this issue Jun 19, 2017 · 2 comments
Assignees

Comments

@hengpor
Copy link

hengpor commented Jun 19, 2017

I noticed there are couple log.Print in loading model and policy config. There should environmental variable to control this log so it will can give developer to switch it on/off between dev and prod version.

@hsluoyz
Copy link
Member

hsluoyz commented Jun 20, 2017

Hi @hengpor ,

I have added the switch to log. Please refer to TestEnableLog in: https://github.com/casbin/casbin/blob/master/enforcer_test.go

func TestEnableLog(t *testing.T) {
	e := NewEnforcer("examples/basic_model.conf", "examples/basic_policy.csv", true)
	// The log is enabled by default, so the above is the same with:
	// e := NewEnforcer("examples/basic_model.conf", "examples/basic_policy.csv")

	testEnforce(t, e, "alice", "data1", "read", true)
	testEnforce(t, e, "alice", "data1", "write", false)
	testEnforce(t, e, "alice", "data2", "read", false)
	testEnforce(t, e, "alice", "data2", "write", false)
	testEnforce(t, e, "bob", "data1", "read", false)
	testEnforce(t, e, "bob", "data1", "write", false)
	testEnforce(t, e, "bob", "data2", "read", false)
	testEnforce(t, e, "bob", "data2", "write", true)

	// The log can also be enabled or disabled at run-time.
	e.EnableLog(false)
	testEnforce(t, e, "alice", "data1", "read", true)
	testEnforce(t, e, "alice", "data1", "write", false)
	testEnforce(t, e, "alice", "data2", "read", false)
	testEnforce(t, e, "alice", "data2", "write", false)
	testEnforce(t, e, "bob", "data1", "read", false)
	testEnforce(t, e, "bob", "data1", "write", false)
	testEnforce(t, e, "bob", "data2", "read", false)
	testEnforce(t, e, "bob", "data2", "write", true)
}

@hsluoyz hsluoyz self-assigned this Jun 20, 2017
@hsluoyz
Copy link
Member

hsluoyz commented Jun 20, 2017

This issue is supposed to be fixed.

@hsluoyz hsluoyz closed this as completed Jun 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants