logging

package
v0.1.451 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: Apache-2.0 Imports: 7 Imported by: 27

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All(items []string) string

All generates a human readable representation of the given list of strings, for use in a log file. It puts quotes around each item, separates the first items with commas and the last with the word 'and'.

func Any

func Any(items []string) string

any generates a human readable representation of the given list of strings, for use in a log file. It puts quotes around each item, separates the first items with commas and the last with the word 'or'.

Types

type GlogLogger

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

GlogLogger is a logger that uses the glog V mechanism.

func (*GlogLogger) Debug

func (l *GlogLogger) 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 (*GlogLogger) DebugEnabled

func (l *GlogLogger) DebugEnabled() bool

DebugEnabled returns true iff the debug level is enabled.

func (*GlogLogger) Error

func (l *GlogLogger) 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 (*GlogLogger) ErrorEnabled

func (l *GlogLogger) ErrorEnabled() bool

ErrorEnabled returns true iff the error level is enabled.

func (*GlogLogger) Fatal

func (l *GlogLogger) 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 (*GlogLogger) Info

func (l *GlogLogger) 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 (*GlogLogger) InfoEnabled

func (l *GlogLogger) InfoEnabled() bool

InfoEnabled returns true iff the information level is enabled.

func (*GlogLogger) Warn

func (l *GlogLogger) 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 (*GlogLogger) WarnEnabled

func (l *GlogLogger) WarnEnabled() bool

WarnEnabled returns true iff the warning level is enabled.

type GlogLoggerBuilder

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

GlogLoggerBuilder contains the configuration and logic needed to build a logger that uses the glog V mechanism. Don't create instances of this type directly, use the NewGlogLoggerBuilder function instead.

func NewGlogLoggerBuilder

func NewGlogLoggerBuilder() *GlogLoggerBuilder

NewGlogLoggerBuilder creates a builder that uses the glog V mechanism. By default errors, warnings and information messages will be written to the log if the level is 0 or greater, and debug messages will be written if the level is 1 or greater. This can be changed using the ErrorV, WarnV, InfoV and DebugV methods of the builder. For example, to write errors and warnings for level 0, information messages for level 1, and debug messages for level 2, you can create the logger like this:

logger, err := client.NewGlobLoggerBuilder().
	ErrorV(0).
	WarnV(0).
	InfoV(1).
	DebugV(2).
	Build()

Once the logger is created these settings can't be changed.

func (*GlogLoggerBuilder) Build

func (b *GlogLoggerBuilder) Build() (logger *GlogLogger, err error)

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

func (*GlogLoggerBuilder) DebugV

DebugV sets the V value that will be used for debug messages.

func (*GlogLoggerBuilder) ErrorV

ErrorV sets the V value that will be used for error messages.

func (*GlogLoggerBuilder) InfoV

InfoV sets the V value that will be used for info messages.

func (*GlogLoggerBuilder) WarnV

WarnV sets the V value that will be used for warn messages.

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 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.

type StdLogger

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

StdLogger is a logger that uses the standard output and error streams, or custom writers.

func (*StdLogger) Debug

func (l *StdLogger) 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 (*StdLogger) DebugEnabled

func (l *StdLogger) DebugEnabled() bool

DebugEnabled returns true iff the debug level is enabled.

func (*StdLogger) Error

func (l *StdLogger) 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 (*StdLogger) ErrorEnabled

func (l *StdLogger) ErrorEnabled() bool

ErrorEnabled returns true iff the error level is enabled.

func (*StdLogger) Fatal

func (l *StdLogger) 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 (*StdLogger) Info

func (l *StdLogger) 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 (*StdLogger) InfoEnabled

func (l *StdLogger) InfoEnabled() bool

InfoEnabled returns true iff the information level is enabled.

func (*StdLogger) Warn

func (l *StdLogger) 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 (*StdLogger) WarnEnabled

func (l *StdLogger) WarnEnabled() bool

WarnEnabled returns true iff the warning level is enabled.

type StdLoggerBuilder

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

StdLoggerBuilder contains the configuration and logic needed to build a logger that uses the standard output and error streams, or custom writers.

func NewStdLoggerBuilder

func NewStdLoggerBuilder() *StdLoggerBuilder

NewStdLoggerBuilder creates a builder that knows how to build a logger that uses the standard output and error streams, or custom writers. By default these loggers will have enabled the information, warning and error levels

func (*StdLoggerBuilder) Build

func (b *StdLoggerBuilder) Build() (logger *StdLogger, err error)

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

func (*StdLoggerBuilder) Debug

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

Debug enables or disables the debug level.

func (*StdLoggerBuilder) Error

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

Error enables or disables the error level.

func (*StdLoggerBuilder) Info

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

Info enables or disables the information level.

func (*StdLoggerBuilder) Streams

func (b *StdLoggerBuilder) Streams(out io.Writer, err io.Writer) *StdLoggerBuilder

Streams sets the standard output and error streams to use. If not used then the logger will use os.Stdout and os.Stderr.

func (*StdLoggerBuilder) Warn

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

Warn enables or disables the warning level.

Jump to

Keyboard shortcuts

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