logger

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2024 License: MIT Imports: 10 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CompatibilityLogger

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

CompatibilityLogger follows a common interface that other packages use, so it can be used in places that expect it.

func NewCompatibilityLogger

func NewCompatibilityLogger(log Logger, prefix, defaultMessage string) CompatibilityLogger

func (CompatibilityLogger) Debug

func (l CompatibilityLogger) Debug(args ...interface{})

func (CompatibilityLogger) Error

func (l CompatibilityLogger) Error(args ...interface{})

func (CompatibilityLogger) Fatal

func (l CompatibilityLogger) Fatal(args ...interface{})

func (CompatibilityLogger) Info

func (l CompatibilityLogger) Info(args ...interface{})

func (CompatibilityLogger) Warn

func (l CompatibilityLogger) Warn(args ...interface{})

type Data

type Data map[string]interface{}

Data is a type alias so that it is easy to add additional data to log lines.

type Logger

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

Logger is a logger instance that contains necessary info needed when logging.

func FromContext

func FromContext(ctx context.Context) Logger

FromContext returns a Logger from the given context.Context. If there is no attached logger, then this will just return a new Logger instance.

func New

func New() Logger

New returns a new configured Logger instance.

func NewWithLevel

func NewWithLevel(level string) Logger

func (Logger) Data

func (log Logger) Data(data Data) Logger

Data adds additional data to every subsequent log line. This data is nested within the "data" field.

func (Logger) Debug

func (log Logger) Debug(message string, fields ...Data)

Debug emits a log line with an "debug" log level.

func (Logger) Err

func (log Logger) Err(err error) Logger

Err adds additional an error object to every subsequent log line. This is meant to be immediately chained to emit the log line.

func (Logger) Error

func (log Logger) Error(message string, fields ...Data)

Error emits a log line with an "error" log level.

func (Logger) Fatal

func (log Logger) Fatal(message string, fields ...Data)

Fatal emits a log line with an "fatal" log level. It also calls os.Exit(1) afterwards.

func (Logger) GetID

func (log Logger) GetID() string

GetID returns the ID that's set on the logger.

func (Logger) ID

func (log Logger) ID(id string) Logger

ID adds an identifier to every subsequent log line.

func (Logger) Info

func (log Logger) Info(message string, fields ...Data)

Info emits a log line with an "info" log level.

func (Logger) Root

func (log Logger) Root(root Data) Logger

Root adds additional data to every subsequent log line. This data is added to the root of the JSON line.

func (Logger) Warn

func (log Logger) Warn(message string, fields ...Data)

Warn emits a log line with an "warn" log level.

func (Logger) WithContext

func (log Logger) WithContext(ctx context.Context) context.Context

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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