log

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CaptureOutput added in v1.2.0

func CaptureOutput(logger Logger, debug bool, fn func() error) error

CaptureOutput redirects stdout and stderr to custom loggers and executes the provided function

Types

type CustomWriter added in v1.2.0

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

CustomWriter forwards log messages to the application's logger

func (*CustomWriter) Write added in v1.2.0

func (cw *CustomWriter) Write(p []byte) (n int, err error)

type Fields

type Fields map[string]string

Fields defines fields to attach to log msgs

type Logger

type Logger interface {
	SetLevel(string)
	With(Fields) *logger
	WithContext(context.Context) context.Context

	Errorf(string, ...interface{})
	Infof(string, ...interface{})
	Warnf(string, ...interface{})
	Debugf(string, ...interface{})
}

Logger provides an interface for all used logger features regardless of logging backend

func FromContext

func FromContext(ctx context.Context) Logger

FromContext returns a Logger from a context if it exists

func NewLogger

func NewLogger(out io.Writer) Logger

NewLogger returns a new Logger

Jump to

Keyboard shortcuts

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