log

package
v1.6.28 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: Apache-2.0 Imports: 2 Imported by: 5,307

Documentation

Index

Constants

View Source
const (
	// TextFormat represents the text logging format.
	TextFormat log.OutputFormat = "text"

	// JSONFormat represents the JSON logging format.
	JSONFormat log.OutputFormat = "json"
)

Supported log output formats.

View Source
const RFC3339NanoFixed = log.RFC3339NanoFixed

RFC3339NanoFixed is time.RFC3339Nano with nanoseconds padded using zeros to ensure the formatted time is always the same number of characters.

Variables

View Source
var G = log.G

G is a shorthand for GetLogger.

View Source
var L = log.L

L is an alias for the standard logger.

Functions

func GetLevel added in v1.6.22

func GetLevel() log.Level

GetLevel returns the current log level.

func GetLogger

func GetLogger(ctx context.Context) *log.Entry

GetLogger retrieves the current logger from the context. If no logger is available, the default logger is returned.

func SetFormat added in v1.6.22

func SetFormat(format OutputFormat) error

SetFormat sets the log output format.

func SetLevel added in v1.6.22

func SetLevel(level string) error

SetLevel sets log level globally. It returns an error if the given level is not supported.

func WithLogger

func WithLogger(ctx context.Context, logger *log.Entry) context.Context

WithLogger returns a new context with the provided logger. Use in combination with logger.WithField(s) for great effect.

Types

type Entry added in v1.6.24

type Entry = log.Entry

Entry is a logging entry.

type Fields added in v1.6.22

type Fields = log.Fields

Fields type to pass to "WithFields".

type Level added in v1.6.22

type Level = log.Level

Level is a logging level.

const (
	// TraceLevel level.
	TraceLevel Level = log.TraceLevel

	// DebugLevel level.
	DebugLevel Level = log.DebugLevel

	// InfoLevel level.
	InfoLevel Level = log.InfoLevel

	// WarnLevel level.
	WarnLevel Level = log.WarnLevel

	// ErrorLevel level
	ErrorLevel Level = log.ErrorLevel

	// FatalLevel level.
	FatalLevel Level = log.FatalLevel

	// PanicLevel level.
	PanicLevel Level = log.PanicLevel
)

Supported log levels.

type OutputFormat added in v1.6.24

type OutputFormat = log.OutputFormat

OutputFormat specifies a log output format.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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