logger

package
v0.0.0-...-e21df8e Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: Apache-2.0 Imports: 10 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitKlog

func InitKlog(log *Logger, level Level) error

This function initialize klog which is used in k8s/go-client

func LogFatalError

func LogFatalError(format string, args ...interface{}) error

By default the Fatal Error log will be in json format, because it's production default.

Types

type Format

type Format string
const (
	JSON Format = "json"
	TEXT Format = "text"
)

func MapFormat

func MapFormat(input string) (Format, error)

func (Format) ToZapEncoder

func (f Format) ToZapEncoder() (zapcore.Encoder, error)

type Level

type Level string
const (
	DEBUG Level = "debug"
	INFO  Level = "info"
	WARN  Level = "warn"
	ERROR Level = "error"
	FATAL Level = "fatal"
)

func MapLevel

func MapLevel(level string) (Level, error)

func (Level) ToZapLevel

func (l Level) ToZapLevel() (zapcore.Level, error)

type Logger

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

func New

func New(format Format, level Level, additionalCores ...zapcore.Core) (*Logger, error)

This function creates logger structure based on given format, level and additional cores

func NewWithAtomicLevel

func NewWithAtomicLevel(format Format, atomicLevel zap.AtomicLevel, additionalCores ...zapcore.Core) (*Logger, error)

This function creates logger structure based on given format, atomicLevel and additional cores AtomicLevel structure allows to change level dynamically

func (*Logger) WithContext

func (l *Logger) WithContext() *zap.SugaredLogger

func (*Logger) WithTracing

func (l *Logger) WithTracing(ctx context.Context) *zap.SugaredLogger

Jump to

Keyboard shortcuts

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