logger

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(ctx context.Context, args ...interface{})

Debug writes a debug level message using the logger from the context.

func DebugKV

func DebugKV(ctx context.Context, message string, kvs ...interface{})

DebugKV writes a message and key-value pairs at the debug level using the logger from the context.

func Debugf

func Debugf(ctx context.Context, format string, args ...interface{})

Debugf writes a formatted debug level message using the logger from the context.

func Error

func Error(ctx context.Context, args ...interface{})

Error writes an error level message using the logger from the context.

func ErrorKV

func ErrorKV(ctx context.Context, message string, kvs ...interface{})

ErrorKV writes a message and key-value pairs at the error level using the logger from the context.

func Errorf

func Errorf(ctx context.Context, format string, args ...interface{})

Errorf writes a formatted error level message using the logger from the context.

func Fatal

func Fatal(ctx context.Context, args ...interface{})

Fatal writes a fatal error level message using the logger from the context and then calls os.Exit(1).

func FatalKV

func FatalKV(ctx context.Context, message string, kvs ...interface{})

FatalKV writes a message and key-value pairs at the fatal error level using the logger from the context and then calls os.Exit(1).

func Fatalf

func Fatalf(ctx context.Context, format string, args ...interface{})

Fatalf writes a formatted fatal error level message using the logger from the context and then calls os.Exit(1).

func FromContext

func FromContext(ctx context.Context) *zap.SugaredLogger

FromContext достает логгер из контекста. Если в контексте логгер не обнаруживается - возвращает глобальный логгер.

func Info

func Info(ctx context.Context, args ...interface{})

Info writes an information level message using the logger from the context.

func InfoKV

func InfoKV(ctx context.Context, message string, kvs ...interface{})

InfoKV writes a message and key-value pairs at the information level using the logger from the context.

func Infof

func Infof(ctx context.Context, format string, args ...interface{})

Infof writes a formatted information level message using the logger from the context.

func Level

func Level() zapcore.Level

Level returns the current logging level of the global logger.

func Logger

func Logger() *zap.SugaredLogger

Logger returns the global logger.

func New

func New(level zapcore.LevelEnabler, options ...zap.Option) *zap.SugaredLogger

New creates a new instance of *zap.SugaredLogger with output in simple console format. If the logging level is not provided, the default level (zap.ErrorLevel) will be used.

func Panic

func Panic(ctx context.Context, args ...interface{})

Panic writes a panic level message using the logger from the context and then calls panic().

func PanicKV

func PanicKV(ctx context.Context, message string, kvs ...interface{})

PanicKV writes a message and key-value pairs at the panic level using the logger from the context and then calls panic().

func Panicf

func Panicf(ctx context.Context, format string, args ...interface{})

Panicf writes a formatted panic level message using the logger from the context and then calls panic().

func SetLogger

func SetLogger(l *zap.SugaredLogger)

SetLogger sets the global logger. This function is not thread-safe.

func ToContext

func ToContext(ctx context.Context, l *zap.SugaredLogger) context.Context

ToContext создает контекст с переданным логгером внутри.

func Warn

func Warn(ctx context.Context, args ...interface{})

Warn writes a warning level message using the logger from the context.

func WarnKV

func WarnKV(ctx context.Context, message string, kvs ...interface{})

WarnKV writes a message and key-value pairs at the warning level using the logger from the context.

func Warnf

func Warnf(ctx context.Context, format string, args ...interface{})

Warnf writes a formatted warning level message using the logger from the context.

func WithFields

func WithFields(ctx context.Context, fields ...zap.Field) context.Context

WithFields создает логгер из уже имеющегося в контексте и устанавливает метаданные, используя типизированные поля.

func WithKV

func WithKV(ctx context.Context, key string, value interface{}) context.Context

WithKV создает логгер из уже имеющегося в контексте и устанавливает метаданные. Принимает ключ и значение, которые будут наследоваться дочерними логгерами.

func WithLevel

func WithLevel(lvl zapcore.Level) zap.Option

WithLevel представляет собой опцию, которая создает логгер с указанным уровнем логирования на основе существующего логгера. Он возвращает zap.Option, который оборачивает существующее ядро в coreWithLevel с указанным уровнем.

func WithName

func WithName(ctx context.Context, name string) context.Context

WithName создает именованный логгер из уже имеющегося в контексте. Дочерние логгеры будут наследовать имена (см пример).

Types

This section is empty.

Jump to

Keyboard shortcuts

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