logger

package
v0.16.2 Latest Latest
Warning

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

Go to latest
Published: May 31, 2024 License: Apache-2.0 Imports: 5 Imported by: 5

Documentation

Index

Constants

View Source
const (
	DebugLevel logLevel = "DEBUG"
	InfoLevel  logLevel = "INFO"
	WarnLevel  logLevel = "WARN"
	ErrorLevel logLevel = "ERROR"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

type Logger struct {
	*zap.SugaredLogger
}

Logger handles all logger from application

func NewLogger

func NewLogger(options LoggerOptions) (*Logger, error)

NewLogger creates a new Logger instance

func (*Logger) ContextLoggingFn

func (logger *Logger) ContextLoggingFn(c *gin.Context) LoggingFn

ContextLoggingFn creates a LoggingFn to be used in places that do not necessarily need access to the gin context

func (*Logger) Debugc

func (logger *Logger) Debugc(c *gin.Context, msg string, keysAndValues ...interface{})

Debugc wraps Debugw provided by zap, adding data from gin request context

func (*Logger) Errorc

func (logger *Logger) Errorc(c *gin.Context, msg string, keysAndValues ...interface{})

Errorc wraps Errorw provided by zap, adding data from gin request context

func (*Logger) Infoc

func (logger *Logger) Infoc(c *gin.Context, msg string, keysAndValues ...interface{})

Infoc wraps Infow provided by zap, adding data from gin request context

func (*Logger) Warnc

func (logger *Logger) Warnc(c *gin.Context, msg string, keysAndValues ...interface{})

Warnc wraps Warnw provided by zap, adding data from gin request context

type LoggerOptions added in v0.5.0

type LoggerOptions struct {
	Debug   bool
	LogJSON bool
}

LoggerOptions are options for constructing a Logger

type LoggingFn

type LoggingFn func(level logLevel, msg string, keysAndValues ...interface{})

LoggingFn is generic logging function with some additional context

Jump to

Keyboard shortcuts

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