logger

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package logger is the logger builder.

Index

Constants

View Source
const (
	KeyRequestID string = "requestID"
	KeyUsername  string = "username"
)

Defines common log fields.

Variables

This section is empty.

Functions

This section is empty.

Types

type LogOptions

type LogOptions struct {
	Name          string
	Development   bool
	DisableCaller bool `mapstructure:"disable-caller"`
}

LogOptions defines options for building a logger.

type Logger

type Logger struct {
	*zap.SugaredLogger
}

func L

func L() *Logger

L returns the global logger.

func NewGinLogger added in v0.3.0

func NewGinLogger() *Logger

NewGinLogger creates a gin logger.

func NewGormLogger added in v0.2.0

func NewGormLogger() *Logger

NewGormLogger creates a gorm logger.

func NewLogger

func NewLogger() *Logger

NewLogger creates a logger.

func (*Logger) Named

func (l *Logger) Named(s string) *Logger

Named adds a new path segment to the logger's name. Segments are joined by periods. By default, Loggers are unnamed.

func (*Logger) Printf

func (l *Logger) Printf(format string, args ...interface{})

Printf logs a message at level Print on the compatibleLogger.

func (*Logger) With

func (l *Logger) With(fields ...interface{}) *Logger

With adds a variadic number of fields to the logging context.

func (*Logger) X

func (l *Logger) X(ctx context.Context) *Logger

X adds requestID and username fields to the logging context.

Jump to

Keyboard shortcuts

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