log

package
v0.0.0-...-35a4376 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InjectLogger

func InjectLogger(ctx context.Context, logger Logger) context.Context

func TryInjectLogger

func TryInjectLogger(ctx context.Context, logger Logger) context.Context

Types

type Config

type Config struct {
	Level    string `json:"level"`
	FilePath string `json:"file_path"`
}

func NewConfig

func NewConfig() Config

func (Config) ApplyOnLogger

func (c Config) ApplyOnLogger(logger Logger) (Logger, error)

func (Config) LoggingLevel

func (c Config) LoggingLevel() Level

func (Config) ValidateConfigFields

func (c Config) ValidateConfigFields() error

type Configurator

type Configurator interface {
	Named(name string) Logger
	WithFields(fields ...Field) Logger
	AddCallerSkip(skip int) Logger
	SetLevel(lvl Level)
	ChangeWriters(writers ...io.Writer)
	WithLevel(lvl Level) Logger
}

type Field

type Field struct {
	Key       string
	Type      FieldType
	Array     bool
	Integer   int64
	String    string
	Interface any
}

func NewField

func NewField(key string, value any) Field

type FieldType

type FieldType uint8
const (
	BoolType FieldType = iota
	StringType
	IntType
	Int64Type
	Int32Type
	Int16Type
	Int8Type
	UintType
	Uint64Type
	Uint32Type
	Uint16Type
	Uint8Type
	ErrorType
	TimeType
	DurationType
	Float64Type
	Float32Type
	ReflectType
)

type Level

type Level int8
const (
	DebugLevel Level = iota
	InfoLevel
	WarningLevel
	ErrorLevel
)

func (Level) String

func (l Level) String() string

type Logger

type Logger interface {
	Debug(msg string, fields ...Field)
	Info(msg string, fields ...Field)
	Warning(msg string, fields ...Field)
	Error(err error, fields ...Field)

	Level() Level
	Configurator
}

func ExtractLogger

func ExtractLogger(ctx context.Context) (Logger, bool)

func MustExtractLogger

func MustExtractLogger(ctx context.Context) Logger

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

func NewWriter

func NewWriter(logger Logger) *Writer

func (Writer) Write

func (w Writer) Write(b []byte) (int, error)

Directories

Path Synopsis
output

Jump to

Keyboard shortcuts

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