infralog

package
v1.6.6 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LevelDefault = levelInfo

	EnvironmentDevelopment = "development"
	EnvironmentProduction  = "production"
	EnvironmentDefault     = EnvironmentProduction
)

Variables

This section is empty.

Functions

func Debug

func Debug(message string, fields ...zap.Field)

func DebugCtx added in v1.6.0

func DebugCtx(ctx context.Context, message string, fields ...zap.Field)

func Error

func Error(message string, fields ...zap.Field)

func ErrorCtx added in v1.6.0

func ErrorCtx(ctx context.Context, message string, fields ...zap.Field)

func Fatal

func Fatal(message string, fields ...zap.Field)

func FatalCtx added in v1.6.0

func FatalCtx(ctx context.Context, message string, fields ...zap.Field)

func Info

func Info(message string, fields ...zap.Field)

func InfoCtx added in v1.6.0

func InfoCtx(ctx context.Context, message string, fields ...zap.Field)

func RegisterLogHandler

func RegisterLogHandler(handler func(entry *LogEntry))

func Setup

func Setup(cfg *Config) *zap.Logger

func Warn

func Warn(message string, fields ...zap.Field)

func WarnCtx added in v1.6.0

func WarnCtx(ctx context.Context, message string, fields ...zap.Field)

func WithField added in v1.6.0

func WithField(ctx context.Context, field zap.Field) context.Context

func WithFields added in v1.6.0

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

Types

type Config

type Config struct {
	Environment       string
	Level             string
	DisableStacktrace bool
}

Config is a logger configuration structure.

func DefaultConfig

func DefaultConfig() *Config

func (*Config) GetLogLevel

func (c *Config) GetLogLevel() zapcore.Level

func (*Config) Validate

func (c *Config) Validate() error

type LogEntry

type LogEntry struct {
	Level   zapcore.Level
	Message string
	Fields  []zap.Field
}

func (*LogEntry) Error

func (e *LogEntry) Error() error

Error searches the first error in the list of entry's fields. Used to extract error from the log entry. We usually have only one error.

Directories

Path Synopsis
examples
ctx

Jump to

Keyboard shortcuts

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