log

package
v2.19.0-pro.5 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DlogLevelNames = [5]string{
	"error",
	"warning",
	"info",
	"debug",
	"trace",
}

Functions

func MakeBaseLogger added in v2.4.7

func MakeBaseLogger(ctx context.Context, logLevel string) context.Context

func NewTestLogger added in v2.4.5

func NewTestLogger(t testing.TB, level dlog.LogLevel) dlog.Logger

func SetLevel

func SetLevel(ctx context.Context, logLevelStr string)

SetLevel sets the log-level for the logger of the given context.

func SetLogrusLevel

func SetLogrusLevel(logrusLogger *logrus.Logger, logLevelStr string, logChange bool)

SetLogrusLevel sets the log-level of the given logger from logLevelStr and logs that to the logger.

func WithDiscardingLogger

func WithDiscardingLogger(ctx context.Context) context.Context

WithDiscardingLogger returns a context that discards all log output.

func WithLevelSetter

func WithLevelSetter(ctx context.Context, logrusLogger *logrus.Logger) context.Context

WithLevelSetter enables setting the log-level of the given Logger by using the returned context as an argument to the SetLevel function.

Types

type Formatter

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

Formatter formats log messages for Telepresence.

func NewFormatter

func NewFormatter(timestampFormat string) *Formatter

func (*Formatter) Format

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

Format implements logrus.Formatter.

type LevelSetter

type LevelSetter func(ctx context.Context, logLevel string)

LevelSetter is a function that sets the log-level.

type TimedLevel

type TimedLevel interface {
	sync.Locker

	// Get returns the current level and the time left until that level
	// is reset to default. An empty string and zero is returned if
	// no level has been set or if it has expired already.
	Get() (string, time.Duration)

	// Set sets a new log-level that will be active for the given duration. If the
	// duration is zero, then the log-level will be active until the next call to
	// Set. If level is the empty string, then duration is ignored and the log-level
	// will be reset to default.
	Set(ctx context.Context, level string, duration time.Duration)

	// Reset restores the log-level to its default value
	Reset(ctx context.Context)
}

TimedLevel is an object capable of setting a log-level for a given time period and then resetting it to a default.

func NewTimedLevel

func NewTimedLevel(defaultLevel string, setter LevelSetter) TimedLevel

NewTimedLevel returns a new TimedLevel for the given default level and setter.

Jump to

Keyboard shortcuts

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