loggerus

package module
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2025 License: Apache-2.0 Imports: 13 Imported by: 3

README

Loggerus

A Nuclio.Logger wrapper for logrus

Usage example:

package myapp

import "github.com/nuclio/loggerus"

// Enrich with who
enrichWhoField := true

// Color output
color := true

// Create a text logger instance
logger, _ := loggerus.NewTextLoggerus("app-logger", logrus.DebugLevel, os.Stdout, enrichWhoField, color)

// Log
logger.Debug("Hello from Loggerus")

// Structured Log
logger.DebugWith("Hello from Loggerus", "someValue", 123)

// Structured Log + context object
logger.DebugWithCtx(ctx, "Hello from Loggerus", "someValue", 123)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JSONFormatter

type JSONFormatter struct {

	// Log time zone
	TimeZone string
	// contains filtered or unexported fields
}

func (*JSONFormatter) Format

func (f *JSONFormatter) Format(entry *logrus.Entry) ([]byte, error)

type Loggerus

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

func NewJSONLoggerus

func NewJSONLoggerus(name string, level logrus.Level, output io.Writer) (*Loggerus, error)

Creates a logger pre-configured for commands

func NewLoggerus

func NewLoggerus(name string, level logrus.Level, output io.Writer, formatter logrus.Formatter) (*Loggerus, error)

func NewLoggerusForTests

func NewLoggerusForTests(name string) (*Loggerus, error)

func NewTextLoggerus

func NewTextLoggerus(name string, level logrus.Level, output io.Writer, enrichWhoField bool, color bool) (*Loggerus, error)

func (*Loggerus) Debug

func (l *Loggerus) Debug(format interface{}, vars ...interface{})

Debug emits an unstructured debug log

func (*Loggerus) DebugCtx

func (l *Loggerus) DebugCtx(ctx context.Context, format interface{}, vars ...interface{})

DebugCtx emits an unstructured debug log with context

func (*Loggerus) DebugWith

func (l *Loggerus) DebugWith(format interface{}, vars ...interface{})

DebugWith emits a structured debug log

func (*Loggerus) DebugWithCtx

func (l *Loggerus) DebugWithCtx(ctx context.Context, format interface{}, vars ...interface{})

DebugWithCtx emits a structured debug log with context

func (*Loggerus) Error

func (l *Loggerus) Error(format interface{}, vars ...interface{})

Error emits an unstructured error log

func (*Loggerus) ErrorCtx

func (l *Loggerus) ErrorCtx(ctx context.Context, format interface{}, vars ...interface{})

ErrorCtx emits an unstructured error log with context

func (*Loggerus) ErrorWith

func (l *Loggerus) ErrorWith(format interface{}, vars ...interface{})

ErrorWith emits a structured error log

func (*Loggerus) ErrorWithCtx

func (l *Loggerus) ErrorWithCtx(ctx context.Context, format interface{}, vars ...interface{})

ErrorWithCtx emits a structured error log with context

func (*Loggerus) Flush

func (l *Loggerus) Flush()

Flush flushes buffered logs, if applicable

func (*Loggerus) GetChild

func (l *Loggerus) GetChild(name string) logger.Logger

GetChild returns a child logger, if underlying logger supports hierarchal logging

func (*Loggerus) GetLogrus

func (l *Loggerus) GetLogrus() *logrus.Logger

func (*Loggerus) GetOutput

func (l *Loggerus) GetOutput() io.Writer

func (*Loggerus) GetRedactor

func (l *Loggerus) GetRedactor() *Redactor

func (*Loggerus) Info

func (l *Loggerus) Info(format interface{}, vars ...interface{})

Info emits an unstructured informational log

func (*Loggerus) InfoCtx

func (l *Loggerus) InfoCtx(ctx context.Context, format interface{}, vars ...interface{})

InfoCtx emits an unstructured informational log with context

func (*Loggerus) InfoWith

func (l *Loggerus) InfoWith(format interface{}, vars ...interface{})

InfoWith emits a structured info log

func (*Loggerus) InfoWithCtx

func (l *Loggerus) InfoWithCtx(ctx context.Context, format interface{}, vars ...interface{})

InfoWithCtx emits a structured info log with context

func (*Loggerus) Warn

func (l *Loggerus) Warn(format interface{}, vars ...interface{})

Warn emits an unstructured warning log

func (*Loggerus) WarnCtx

func (l *Loggerus) WarnCtx(ctx context.Context, format interface{}, vars ...interface{})

WarnCtx emits an unstructured warning log with context

func (*Loggerus) WarnWith

func (l *Loggerus) WarnWith(format interface{}, vars ...interface{})

WarnWith emits a structured warning log

func (*Loggerus) WarnWithCtx

func (l *Loggerus) WarnWithCtx(ctx context.Context, format interface{}, vars ...interface{})

WarnWithCtx emits a structured warning log with context

type MuxLogger

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

a logger that 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 RedactingLogger

type RedactingLogger interface {
	GetRedactor() *Redactor
	GetOutput() io.Writer
}

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)

func (*Redactor) AddValueRedactions

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

func (*Redactor) Disable

func (r *Redactor) Disable()

func (*Redactor) Enable

func (r *Redactor) Enable()

func (*Redactor) GetOutput

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

func (*Redactor) GetRedactions

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

func (*Redactor) Write

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

type TextFormatter

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

func NewTextFormatter

func NewTextFormatter(maxVariableLen int,
	enrichWhoField bool,
	color bool,
	contextFormatter func(context.Context) string) (*TextFormatter, error)

func (*TextFormatter) Format

func (f *TextFormatter) Format(entry *logrus.Entry) ([]byte, error)

Jump to

Keyboard shortcuts

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