logging

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GoLogger

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

GoLogger is a logger that uses the Go `log` package.

func (*GoLogger) Debug

func (l *GoLogger) Debug(ctx context.Context, format string, args ...interface{})

Debug sends to the log a debug message formatted using the fmt.Sprintf function and the given format and arguments.

func (*GoLogger) DebugEnabled

func (l *GoLogger) DebugEnabled() bool

DebugEnabled returns true iff the debug level is enabled.

func (*GoLogger) Error

func (l *GoLogger) Error(ctx context.Context, format string, args ...interface{})

Error sends to the log an error message formatted using the fmt.Sprintf function and the given format and arguments.

func (*GoLogger) ErrorEnabled

func (l *GoLogger) ErrorEnabled() bool

ErrorEnabled returns true iff the error level is enabled.

func (*GoLogger) Fatal

func (l *GoLogger) Fatal(ctx context.Context, format string, args ...interface{})

Fatal sends to the log an error message formatted using the fmt.Sprintf function and the given format and arguments. After that it will os.Exit(1) This level is always enabled

func (*GoLogger) Info

func (l *GoLogger) Info(ctx context.Context, format string, args ...interface{})

Info sends to the log an information message formatted using the fmt.Sprintf function and the given format and arguments.

func (*GoLogger) InfoEnabled

func (l *GoLogger) InfoEnabled() bool

InfoEnabled returns true iff the information level is enabled.

func (*GoLogger) Warn

func (l *GoLogger) Warn(ctx context.Context, format string, args ...interface{})

Warn sends to the log a warning message formatted using the fmt.Sprintf function and the given format and arguments.

func (*GoLogger) WarnEnabled

func (l *GoLogger) WarnEnabled() bool

WarnEnabled returns true iff the warning level is enabled.

type GoLoggerBuilder

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

GoLoggerBuilder contains the configuration and logic needed to build a logger that uses the Go `log` package. Don't create instances of this type directly, use the NewGoLoggerBuilder function instead.

func NewGoLoggerBuilder

func NewGoLoggerBuilder() *GoLoggerBuilder

NewGoLoggerBuilder creates a builder that knows how to build a logger that uses the Go `log` package. By default these loggers will have enabled the information, warning and error levels

func (*GoLoggerBuilder) Build

func (b *GoLoggerBuilder) Build() (logger *GoLogger, err error)

Build creates a new logger using the configuration stored in the builder.

func (*GoLoggerBuilder) Debug

func (b *GoLoggerBuilder) Debug(flag bool) *GoLoggerBuilder

Debug enables or disables the debug level.

func (*GoLoggerBuilder) Error

func (b *GoLoggerBuilder) Error(flag bool) *GoLoggerBuilder

Error enables or disables the error level.

func (*GoLoggerBuilder) Info

func (b *GoLoggerBuilder) Info(flag bool) *GoLoggerBuilder

Info enables or disables the information level.

func (*GoLoggerBuilder) Warn

func (b *GoLoggerBuilder) Warn(flag bool) *GoLoggerBuilder

Warn enables or disables the warning level.

type Level

type Level int
const (
	Fatal Level = iota // 0
	Error
	Warning
	Info
	Debug
)

type Logger

type Logger interface {
	// DebugEnabled returns true if the debug level is enabled.
	DebugEnabled() bool

	// InfoEnabled returns true if the information level is enabled.
	InfoEnabled() bool

	// WarnEnabled returns true if the warning level is enabled.
	WarnEnabled() bool

	// ErrorEnabled returns true if the error level is enabled.
	ErrorEnabled() bool

	// Debug sends to the log a debug message formatted using the fmt.Sprintf function and the
	// given format and arguments.
	Debug(ctx context.Context, format string, args ...interface{})

	// Info sends to the log an information message formatted using the fmt.Sprintf function and
	// the given format and arguments.
	Info(ctx context.Context, format string, args ...interface{})

	// Warn sends to the log a warning message formatted using the fmt.Sprintf function and the
	// given format and arguments.
	Warn(ctx context.Context, format string, args ...interface{})

	// Error sends to the log an error message formatted using the fmt.Sprintf function and the
	// given format and arguments.
	Error(ctx context.Context, format string, args ...interface{})

	// Fatal sends to the log an error message formatted using the fmt.Sprintf function and the
	// given format and arguments; and then executes an os.Exit(1)
	// Fatal level is always enabled
	Fatal(ctx context.Context, format string, args ...interface{})
}

Logger is the interface that must be implemented by objects that are used for logging by the client. By default the client uses a logger based on the `glog` package, but that can be changed using the `Logger` method of the builder.

Note that the context is optional in most of the methods of the SDK, so implementations of this interface must accept and handle smoothly calls to the Debug, Info, Warn and Error methods where the ctx parameter is nil.

Jump to

Keyboard shortcuts

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