zaplogger

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2020 License: Apache-2.0 Imports: 2 Imported by: 0

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 let your enforcer use this logger when you first initialize your enforcer like:

e, _ := casbin.NewEnforcer("examples/rbac_model.conf", a, zaplogger.NewLogger(true, true), true)

or with and existing zap instance.

logger := zaplogger.NewLoggerByZap(yourZapLogger, true)
e, _ := casbin.NewEnforcer("examples/rbac_model.conf", a, logger, true)

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

License

This project is under Apache 2.0 License. See the LICENSE file for the full license text.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger is the implementation for a Logger using zap.

func NewLogger

func NewLogger(enabled, jsonEncode bool) *Logger

NewLogger is the default constructor for Logger. Params : enabled, jsonEncode enabled initialize recording state, jsonEncode initialize log whether structured as json.

func NewLoggerByZap

func NewLoggerByZap(zapLogger *zap.Logger, enabled bool) *Logger

NewLoggerByZap creates zap-logger by an existing zap instance.

func (*Logger) EnableLog

func (l *Logger) EnableLog(enable bool)

func (*Logger) IsEnabled

func (l *Logger) IsEnabled() bool

func (*Logger) LogEnforce

func (l *Logger) LogEnforce(event int, line string, request *[]interface{}, policies *[]string, result *[]interface{})

func (*Logger) LogModel

func (l *Logger) LogModel(event int, line []string, model [][]string)

func (*Logger) LogPolicy

func (l *Logger) LogPolicy(event int, line string, pPolicyFormat []string, gPolicyFormat []string, pPolicy *[]interface{}, gPolicy *[]interface{})

func (*Logger) LogRole

func (l *Logger) LogRole(event int, line string, role []string)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL