log

package
v0.0.0-...-65dff4a Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DebugLevel logs are typically voluminous, and are usually disabled in
	// production.
	DebugLevel = zap.DebugLevel
	// InfoLevel is the default logging priority.
	InfoLevel = zap.InfoLevel
	// WarnLevel logs are more important than Info, but don't need individual
	// human review.
	WarnLevel = zap.WarnLevel
	// ErrorLevel logs are high-priority. If an application is running smoothly,
	// it shouldn't generate any error-level logs.
	ErrorLevel = zap.ErrorLevel
	// DPanicLevel logs are particularly important errors. In development the
	// logger panics after writing the message.
	DPanicLevel = zap.DPanicLevel
	// PanicLevel logs a message, then panics.
	PanicLevel = zap.PanicLevel
	// FatalLevel logs a message, then calls os.Exit(1).
	FatalLevel = zap.FatalLevel
)

Duplicated constants from zap for more intuitive usage

View Source
const (
	// ProductionEnv sets production config (json encoder, etc)
	ProductionEnv = "production"
	// DevelopmentEnv adjusts config for development
	DevelopmentEnv = "development"
)

Variables

This section is empty.

Functions

func Debug

func Debug(args ...interface{})

Debug calls log.Debug

func Debugf

func Debugf(template string, args ...interface{})

Debugf calls log.Debugf

func Debugw

func Debugw(template string, kv ...interface{})

Debugw calls log.Debugw

func Error

func Error(args ...interface{})

Error calls log.Error

func Errorf

func Errorf(template string, args ...interface{})

Errorf calls log.Errorf and stores the error message into the ErrorFile

func Errorw

func Errorw(template string, kv ...interface{})

Errorw calls log.Errorw

func Fatal

func Fatal(args ...interface{})

Fatal calls log.Fatal

func Fatalf

func Fatalf(template string, args ...interface{})

Fatalf calls log.Warnf

func Fatalw

func Fatalw(template string, kv ...interface{})

Fatalw calls log.Fatalw

func Info

func Info(args ...interface{})

Info calls log.Info

func Infof

func Infof(template string, args ...interface{})

Infof calls log.Infof

func Infow

func Infow(template string, kv ...interface{})

Infow calls log.Infow

func NewLogger

func NewLogger(env, levelStr string, outputs []string) (*zap.SugaredLogger, *zap.AtomicLevel, error)

NewLogger creates the logger with defined level. outputs defines the outputs where the logs will be sent. By default, outputs contains "stdout", which prints the logs at the output of the process. To add a log file as output, the path should be added at the outputs array. To avoid printing the logs but storing them on a file, can use []string{"pathtofile.log"}

func SetEnv

func SetEnv(env string)

SetEnv sets logger with config depending on the env provided

func SetLevel

func SetLevel(level zapcore.Level)

SetLevel sets level of default logger

func SetLevelStr

func SetLevelStr(_levelStr string)

SetLevelStr sets level of default logger from level name Valid values: debug, info, warn, error, dpanic, panic, fatal

func Sync

func Sync()

Sync flushes buffers to log storage.

func Warn

func Warn(args ...interface{})

Warn calls log.Warn

func Warnf

func Warnf(template string, args ...interface{})

Warnf calls log.Warnf

func Warnw

func Warnw(template string, kv ...interface{})

Warnw calls log.Warnw

Types

type DebugLogger

type DebugLogger interface {
	Debug(args ...interface{})
	Debugf(template string, args ...interface{})
	Debugw(template string, kv ...interface{})
}

DebugLogger Debug* log functions

type ErrorLogger

type ErrorLogger interface {
	Error(args ...interface{})
	Errorf(template string, args ...interface{})
	Errorw(template string, kv ...interface{})
}

ErrorLogger Error* log functions

type FatalLogger

type FatalLogger interface {
	Fatal(args ...interface{})
	Fatalf(template string, args ...interface{})
	Fatalw(template string, kv ...interface{})
}

FatalLogger Fatal* log functions

type InfoLogger

type InfoLogger interface {
	Info(args ...interface{})
	Infof(template string, args ...interface{})
	Infow(template string, kv ...interface{})
}

InfoLogger Info* log functions

type Logger

Logger is an umbrella interface for all log functions

func WithContext

func WithContext(ctx context.Context) Logger

WithContext creates new logger with wrapped context that would be used to extract request-id value.

type WarnLogger

type WarnLogger interface {
	Warn(args ...interface{})
	Warnf(template string, args ...interface{})
	Warnw(template string, kv ...interface{})
}

WarnLogger Warn* log functions

Jump to

Keyboard shortcuts

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