nucliozap

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2023 License: Apache-2.0 Imports: 14 Imported by: 47

README

zap

A Nuclio.Logger wrapper for zap

Documentation

Index

Constants

View Source
const DefaultVarGroupMode = VarGroupModeFlattened

Variables

View Source
var ErrBufferPoolAllocationTimeout = errors.New("Timed out waiting for buffer logger")

Functions

This section is empty.

Types

type BufferLogger

type BufferLogger struct {
	Logger *NuclioZap
	Buffer *bytes.Buffer
	// contains filtered or unexported fields
}

BufferLogger is a logger who outputs the records to a buffer

func NewBufferLogger

func NewBufferLogger(name string, encoding string, level Level) (*BufferLogger, error)

NewBufferLogger creates a logger that is able to capture the output into a buffer. if a request arrives and the user wishes to capture the log, this will be used as the logger instead of the default logger

func NewBufferLoggerWithRedactor

func NewBufferLoggerWithRedactor(name string, encoding string, level Level, redactor *Redactor) (*BufferLogger, error)

func (*BufferLogger) GetJSONString

func (bl *BufferLogger) GetJSONString() (string, error)

func (*BufferLogger) GetLogEntries

func (bl *BufferLogger) GetLogEntries() ([]map[string]interface{}, error)

type BufferLoggerPool

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

BufferLoggerPool is a pool for buffer loggers

func NewBufferLoggerPool

func NewBufferLoggerPool(numBufferLoggers int,
	name string,
	encoding string,
	level Level) (*BufferLoggerPool, error)

func (*BufferLoggerPool) Allocate

func (blp *BufferLoggerPool) Allocate(timeout *time.Duration) (*BufferLogger, error)

func (*BufferLoggerPool) Release

func (blp *BufferLoggerPool) Release(bufferLogger *BufferLogger)

type EncoderConfig

type EncoderConfig struct {
	JSON    EncoderConfigJSON
	Console EncoderConfigConsole
}

func NewEncoderConfig

func NewEncoderConfig() *EncoderConfig

type EncoderConfigConsole

type EncoderConfigConsole struct {
}

type EncoderConfigJSON

type EncoderConfigJSON struct {
	LineEnding        string
	VarGroupName      string
	VarGroupMode      VarGroupMode
	TimeFieldName     string
	TimeFieldEncoding string
	ReflectedEncoder  func(writer io.Writer) zapcore.ReflectedEncoder
}

type Level

type Level int8

Level is logging levels

const (
	DebugLevel  Level = Level(zapcore.DebugLevel)
	InfoLevel   Level = Level(zapcore.InfoLevel)
	WarnLevel   Level = Level(zapcore.WarnLevel)
	ErrorLevel  Level = Level(zapcore.ErrorLevel)
	DPanicLevel Level = Level(zapcore.DPanicLevel)
	PanicLevel  Level = Level(zapcore.PanicLevel)
	FatalLevel  Level = Level(zapcore.FatalLevel)
)

Predefined logging levels

func GetLevelByName

func GetLevelByName(levelName string) Level

GetLevelByName return logging level by name

type MuxLogger

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

MuxLogger multiplexes logs towards multiple loggers

func NewMuxLogger

func NewMuxLogger(loggers ...logger.Logger) (*MuxLogger, error)

func (*MuxLogger) Debug

func (ml *MuxLogger) Debug(format interface{}, vars ...interface{})

func (*MuxLogger) DebugCtx

func (ml *MuxLogger) DebugCtx(ctx context.Context, format interface{}, vars ...interface{})

func (*MuxLogger) DebugWith

func (ml *MuxLogger) DebugWith(format interface{}, vars ...interface{})

func (*MuxLogger) DebugWithCtx

func (ml *MuxLogger) DebugWithCtx(ctx context.Context, format interface{}, vars ...interface{})

func (*MuxLogger) Error

func (ml *MuxLogger) Error(format interface{}, vars ...interface{})

func (*MuxLogger) ErrorCtx

func (ml *MuxLogger) ErrorCtx(ctx context.Context, format interface{}, vars ...interface{})

func (*MuxLogger) ErrorWith

func (ml *MuxLogger) ErrorWith(format interface{}, vars ...interface{})

func (*MuxLogger) ErrorWithCtx

func (ml *MuxLogger) ErrorWithCtx(ctx context.Context, format interface{}, vars ...interface{})

func (*MuxLogger) Flush

func (ml *MuxLogger) Flush()

func (*MuxLogger) GetChild

func (ml *MuxLogger) GetChild(name string) logger.Logger

func (*MuxLogger) GetLoggers

func (ml *MuxLogger) GetLoggers() []logger.Logger

func (*MuxLogger) Info

func (ml *MuxLogger) Info(format interface{}, vars ...interface{})

func (*MuxLogger) InfoCtx

func (ml *MuxLogger) InfoCtx(ctx context.Context, format interface{}, vars ...interface{})

func (*MuxLogger) InfoWith

func (ml *MuxLogger) InfoWith(format interface{}, vars ...interface{})

func (*MuxLogger) InfoWithCtx

func (ml *MuxLogger) InfoWithCtx(ctx context.Context, format interface{}, vars ...interface{})

func (*MuxLogger) SetLoggers

func (ml *MuxLogger) SetLoggers(loggers ...logger.Logger)

func (*MuxLogger) Warn

func (ml *MuxLogger) Warn(format interface{}, vars ...interface{})

func (*MuxLogger) WarnCtx

func (ml *MuxLogger) WarnCtx(ctx context.Context, format interface{}, vars ...interface{})

func (*MuxLogger) WarnWith

func (ml *MuxLogger) WarnWith(format interface{}, vars ...interface{})

func (*MuxLogger) WarnWithCtx

func (ml *MuxLogger) WarnWithCtx(ctx context.Context, format interface{}, vars ...interface{})

type NuclioZap

type NuclioZap struct {
	*zap.SugaredLogger
	// contains filtered or unexported fields
}

NuclioZap is a concrete implementation of the nuclio logger interface, using zap

func NewNuclioZap

func NewNuclioZap(name string,
	encoding string,
	customEncoderConfig *EncoderConfig,
	sink io.Writer,
	errSink io.Writer,
	level Level) (*NuclioZap, error)

NewNuclioZap create a configurable logger

func NewNuclioZapCmd

func NewNuclioZapCmd(name string, level Level, writer io.Writer) (*NuclioZap, error)

NewNuclioZapCmd creates a logger pre-configured for commands

func NewNuclioZapTest

func NewNuclioZapTest(name string) (*NuclioZap, error)

NewNuclioZapTest creates a logger pre-configured for tests

func (*NuclioZap) Debug

func (nz *NuclioZap) Debug(format interface{}, vars ...interface{})

Debug emits debug level log

func (*NuclioZap) DebugCtx

func (nz *NuclioZap) DebugCtx(ctx context.Context, format interface{}, vars ...interface{})

DebugCtx emits an unstructured debug log with context

func (*NuclioZap) DebugWith

func (nz *NuclioZap) DebugWith(format interface{}, vars ...interface{})

DebugWith emits debug level log with arguments

func (*NuclioZap) DebugWithCtx

func (nz *NuclioZap) DebugWithCtx(ctx context.Context, format interface{}, vars ...interface{})

DebugWithCtx emits debug level log with arguments

func (*NuclioZap) Error

func (nz *NuclioZap) Error(format interface{}, vars ...interface{})

Errors emits error level log

func (*NuclioZap) ErrorCtx

func (nz *NuclioZap) ErrorCtx(ctx context.Context, format interface{}, vars ...interface{})

ErrorCtx emits an unstructured debug log with context

func (*NuclioZap) ErrorWith

func (nz *NuclioZap) ErrorWith(format interface{}, vars ...interface{})

ErrorWith emits error level log with arguments

func (*NuclioZap) ErrorWithCtx

func (nz *NuclioZap) ErrorWithCtx(ctx context.Context, format interface{}, vars ...interface{})

ErrorWithCtx emits debug level log with arguments

func (*NuclioZap) Flush

func (nz *NuclioZap) Flush()

Flush flushes the log

func (*NuclioZap) GetChild

func (nz *NuclioZap) GetChild(name string) logger.Logger

GetChild returned a named child logger

func (*NuclioZap) GetLevel

func (nz *NuclioZap) GetLevel() Level

GetLevel returns the current logging level

func (*NuclioZap) GetRedactor

func (nz *NuclioZap) GetRedactor() *Redactor

func (*NuclioZap) Info

func (nz *NuclioZap) Info(format interface{}, vars ...interface{})

Info emits info level log

func (*NuclioZap) InfoCtx

func (nz *NuclioZap) InfoCtx(ctx context.Context, format interface{}, vars ...interface{})

InfoCtx emits an unstructured debug log with context

func (*NuclioZap) InfoWith

func (nz *NuclioZap) InfoWith(format interface{}, vars ...interface{})

InfoWith emits info level log with arguments

func (*NuclioZap) InfoWithCtx

func (nz *NuclioZap) InfoWithCtx(ctx context.Context, format interface{}, vars ...interface{})

InfoWithCtx emits debug level log with arguments

func (*NuclioZap) SetLevel

func (nz *NuclioZap) SetLevel(level Level)

SetLevel sets the logging level

func (*NuclioZap) Warn

func (nz *NuclioZap) Warn(format interface{}, vars ...interface{})

Warn emits warn level log

func (*NuclioZap) WarnCtx

func (nz *NuclioZap) WarnCtx(ctx context.Context, format interface{}, vars ...interface{})

WarnCtx emits an unstructured debug log with context

func (*NuclioZap) WarnWith

func (nz *NuclioZap) WarnWith(format interface{}, vars ...interface{})

WarnWith emits warn level log with arguments

func (*NuclioZap) WarnWithCtx

func (nz *NuclioZap) WarnWithCtx(ctx context.Context, format interface{}, vars ...interface{})

WarnWithCtx emits debug level log with arguments

type RedactingLogger

type RedactingLogger interface {

	// GetOutput returns redactor writer
	GetOutput() io.Writer

	// GetRedactor returns redactor instance
	GetRedactor() *Redactor
}

type Redactor

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

func NewRedactor

func NewRedactor(output io.Writer) *Redactor

func (*Redactor) AddRedactions

func (r *Redactor) AddRedactions(redactions []string)

AddRedactions redacts simple strings

func (*Redactor) AddValueRedactions

func (r *Redactor) AddValueRedactions(valueRedactions []string)

AddValueRedactions redacts key:[value] or key=[value] kind of strings

func (*Redactor) Disable

func (r *Redactor) Disable()

func (*Redactor) Enable

func (r *Redactor) Enable()

func (*Redactor) GetOutput

func (r *Redactor) GetOutput() io.Writer

GetOutput returns redactor writer

func (*Redactor) GetRedactions

func (r *Redactor) GetRedactions() [][]byte

func (*Redactor) SetDisabled

func (r *Redactor) SetDisabled(disable bool)

SetDisabled turns logger redaction on/off

func (*Redactor) SetOutput

func (r *Redactor) SetOutput(output io.Writer)

SetOutput sets redactor output

func (*Redactor) Write

func (r *Redactor) Write(p []byte) (n int, err error)

Write writes to output

type VarGroupMode

type VarGroupMode string
const (
	VarGroupModeFlattened  VarGroupMode = "flattened"
	VarGroupModeStructured VarGroupMode = "structured"
)

Jump to

Keyboard shortcuts

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