log

package
v1.104.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2024 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddField added in v1.104.0

func AddField(ctx context.Context, key string, value any)

AddField adds a field to the context logger.

func SetJww added in v1.7.1

func SetJww(verbose bool, w io.Writer)

SetJww sets jww log when debug enabled.

func ToContext added in v1.104.0

func ToContext(ctx context.Context, logger *Logger) context.Context

ToContext adds the log.Logger to the context for extraction later. Returning the new context that has been created.

Types

type DynamicWriteSyncer added in v1.104.0

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

DynamicWriteSyncer allows changing the underlying WriteSyncer at runtime.

func NewDynamicWriteSyncer added in v1.104.0

func NewDynamicWriteSyncer(initial zapcore.WriteSyncer) *DynamicWriteSyncer

NewDynamicWriteSyncer initializes the dynamic writer with an initial writer.

func (*DynamicWriteSyncer) SetWriter added in v1.104.0

func (d *DynamicWriteSyncer) SetWriter(newWriter zapcore.WriteSyncer)

SetWriter allows updating the underlying writer at runtime.

func (*DynamicWriteSyncer) Sync added in v1.104.0

func (d *DynamicWriteSyncer) Sync() error

Sync calls Sync on the current writer.

func (*DynamicWriteSyncer) Write added in v1.104.0

func (d *DynamicWriteSyncer) Write(p []byte) (n int, err error)

Write writes the log entry to the current writer.

type Logger added in v1.104.0

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

Logger is the log entry.

func Extract added in v1.104.0

func Extract(ctx context.Context) *Logger

Extract takes the call-scoped Logger.

func New added in v1.104.0

func New(dest io.Writer, opts ...Option) *Logger

New creates a new Logger that writes to dest.

func (*Logger) Debugf added in v1.104.0

func (l *Logger) Debugf(format string, args ...any)

Debugf logs a message at level Debug.

func (*Logger) Debugln added in v1.104.0

func (l *Logger) Debugln(msg string)

Debugln logs a message at level Debug.

func (*Logger) Errorf added in v1.104.0

func (l *Logger) Errorf(format string, args ...any)

Errorf logs a message at level Error.

func (*Logger) Errorln added in v1.104.0

func (l *Logger) Errorln(msg string)

Errorln logs a message at level Error.

func (*Logger) Fatalf added in v1.104.0

func (l *Logger) Fatalf(format string, args ...any)

Fatalf logs a message at level Fatal then the process will exit with status set to 1.

func (*Logger) Fatalln added in v1.104.0

func (l *Logger) Fatalln(msg string)

Fatalln logs a message at level Fatal then the process will exit with status set to 1.

func (*Logger) Flush added in v1.104.0

func (l *Logger) Flush()

Flush flushes the log output and closes the file.

func (*Logger) Infof added in v1.104.0

func (l *Logger) Infof(format string, args ...any)

Infof logs a message at level Info.

func (*Logger) Infoln added in v1.104.0

func (l *Logger) Infoln(msg string)

Infoln logs a message at level Info.

func (*Logger) IsMetricsEnabled added in v1.104.0

func (l *Logger) IsMetricsEnabled() bool

IsMetricsEnabled returns true if it should collect metrics.

func (*Logger) IsVerboseEnabled added in v1.104.0

func (l *Logger) IsVerboseEnabled() bool

IsVerboseEnabled returns true if debug is enabled.

func (*Logger) Output added in v1.104.0

func (l *Logger) Output() io.Writer

Output returns the current log output.

func (*Logger) SendDiagsOnErrors added in v1.104.0

func (l *Logger) SendDiagsOnErrors() bool

SendDiagsOnErrors returns true if diagnostics should be sent on errors.

func (*Logger) SetOutput added in v1.104.0

func (l *Logger) SetOutput(w io.Writer)

SetOutput defines sets the log output to io.Writer.

func (*Logger) SetVerbose added in v1.104.0

func (l *Logger) SetVerbose(verbose bool)

SetVerbose sets log level to debug if enabled.

func (*Logger) Warnf added in v1.104.0

func (l *Logger) Warnf(format string, args ...any)

Warnf logs a message at level Warn.

func (*Logger) Warnln added in v1.104.0

func (l *Logger) Warnln(msg string)

Warnln logs a message at level Warn.

func (*Logger) WithField added in v1.104.0

func (l *Logger) WithField(key string, value any)

WithField adds a single field to the Logger.

type Option added in v1.104.0

type Option func(*Logger)

Option is a functional option for Logger.

func WithMetrics added in v1.104.0

func WithMetrics(metrics bool) Option

WithMetrics sets metrics mode.

func WithSendDiagsOnErrors added in v1.104.0

func WithSendDiagsOnErrors(sendDiagsOnErrors bool) Option

WithSendDiagsOnErrors sets send diagnostics on errors mode.

func WithVerbose added in v1.104.0

func WithVerbose(verbose bool) Option

WithVerbose sets verbose mode.

Jump to

Keyboard shortcuts

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