https://github.com/casbin/zap-logger
Zap logger for Casbin
https://github.com/casbin/zap-logger
abac access-control acl auth authz casbin log logger rbac zap
Last synced: 3 months ago
JSON representation
Zap logger for Casbin
- Host: GitHub
- URL: https://github.com/casbin/zap-logger
- Owner: casbin
- License: apache-2.0
- Created: 2020-10-21T08:18:02.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-09-24T12:07:13.000Z (over 2 years ago)
- Last Synced: 2025-10-13T06:22:59.189Z (7 months ago)
- Topics: abac, access-control, acl, auth, authz, casbin, log, logger, rbac, zap
- Language: Go
- Homepage: https://github.com/casbin/casbin
- Size: 27.3 KB
- Stars: 5
- Watchers: 1
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Zap Logger
Zap logger is the Zap logger for Casbin. With this library, Casbin can log information more powerful.
## Installation
go get github.com/casbin/zap-logger
## How to use it
You could import the zap-logger module like:
```
import (
zaplogger "github.com/casbin/zap-logger/v3"
"github.com/casbin/casbin/v3"
)
```
You could let your enforcer use this logger when you first initialize your enforcer like:
```go
e, _ := casbin.NewEnforcer("examples/rbac_model.conf", a)
e.EnableLog(true)
e.SetLogger(zaplogger.NewLogger(true, true))
```
or with and existing zap instance.
```go
logger := zaplogger.NewLoggerByZap(yourZapLogger, true)
e, _ := casbin.NewEnforcer("examples/rbac_model.conf", a)
e.EnableLog(true)
e.SetLogger(logger)
```
And the method `NewLogger` have two params: enabled and jsonEncode, you could initialize logger's log status and decide whether to output information with json encoded or not.
## Getting Help
- [Casbin](https://github.com/casbin/casbin)
## License
This project is under Apache 2.0 License. See the [LICENSE](LICENSE) file for the full license text.