logger

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	LevelInfo  = zap.InfoLevel.CapitalString()
	LevelDebug = zap.DebugLevel.CapitalString()
)

Functions

func Debug

func Debug(msg string, tags ...zapcore.Field)

Debug logs a message at the zap.DebugLevel. Additional fields can be added to the logger using tags.

func Debugf

func Debugf(format string, a ...any)

Debugf logs a formatted message at the zap.DebugLevel.

func Error

func Error(msg string, tags ...zapcore.Field)

Error logs a message at the zap.ErrorLevel. Additional fields can be added to the logger using tags.

func Errorf

func Errorf(format string, a ...any)

Errorf logs a formatted message at the zap.ErrorLevel.

func Fatal

func Fatal(msg string, tags ...zapcore.Field)

Fatal logs a message at the zap.FatalLevel. Additional fields can be added to the logger using tags.

func Fatalf

func Fatalf(format string, a ...any)

Fatalf logs a formatted message at the zap.FatalLevel.

func GinZap

func GinZap() gin.HandlerFunc

GinZap returns a gin.HandlerFunc (middleware) that logs requests using uber-go/zap. Requests with errors are logged using zap.Error(). Requests without errors are logged using zap.Info().

func Info

func Info(msg string, tags ...zapcore.Field)

Info logs a message at the zap.InfoLevel. Additional fields can be added to the logger using tags.

func Infof

func Infof(format string, a ...any)

Infof logs a formatted message at the zap.InfoLevel.

func Panic

func Panic(msg string, tags ...zapcore.Field)

Panic logs a message at the zap.PanicLevel. Additional fields can be added to the logger using tags.

func Panicf

func Panicf(format string, a ...any)

Panicf logs a formatted message at the zap.PanicLevel.

func RestyDebugLogger

func RestyDebugLogger(resp *resty.Response)

RestyDebugLogger prints debug logs for a http request based on the resty.Response.

func SetLogger

func SetLogger(opts ...Option)

SetLogger sets the desired loglevel and re-initializes the logger util.

func SetLoggerWithConfig

func SetLoggerWithConfig(config zap.Config)

SetLoggerWithConfig initializes the logger util with a custom configuration.

func Warn

func Warn(msg string, tags ...zapcore.Field)

Warn logs a message at the zap.WarnLevel. Additional fields can be added to the logger using tags.

func Warnf

func Warnf(format string, a ...any)

Warnf logs a formatted message at the zap.WarnLevel.

Types

type Config

type Config struct {
	Level       *zapcore.Level
	OutputPaths []string
}

type Option

type Option func(config *Config)

func WithLogLevel

func WithLogLevel(logLevel string) Option

WithLogLevel is an option that can be used to define a custom log level Currently only INFO (default) and DEBUG are supported

func WithOutputPaths

func WithOutputPaths(outputPaths []string) Option

WithOutputPaths is an option that can be used to define custom log output paths. Default path is stdout.

Jump to

Keyboard shortcuts

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