xlog

package
v0.0.0-...-f39ad0c Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2023 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorLevel = Level(iota)
	InfoLevel
	DebugLevel
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Level

type Level int

Level indicates the severity of the logging message.

type Logger

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

Logger is a wrapper over a sink to provide a clean API over the core log function.

func New

func New(sink Sink) Logger

New returns a logger for the provided sink.

func (Logger) Debugf

func (l Logger) Debugf(ctx context.Context, format string, args ...interface{})

Debugf is intended to be used only while debugging.

func (Logger) Errorf

func (l Logger) Errorf(ctx context.Context, format string, args ...interface{})

Errorf is intended for the logging of errors that we could not easily return to the client but that caused problems internally.

func (Logger) Infof

func (l Logger) Infof(ctx context.Context, format string, args ...interface{})

Infof is intended for logging of messages that may help the user understand the behavior or be useful in a bug report.

type Sink

type Sink interface {
	Log(ctx context.Context, level Level, message string)
}

Sink is the interface to something that consumes logging messages. This can be implemented and then registered with a context to control the destination or formatting of logging.

type StdSink

type StdSink struct{}

StdSink is a Sink that writes to the standard log package.

func (StdSink) Log

func (StdSink) Log(ctx context.Context, level Level, message string)

Log implements Sink for the StdSink. It writes the message using log.Print with a level based prefix.

Jump to

Keyboard shortcuts

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