sklogimpl

package
v0.0.0-...-47e0bda Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Flush

func Flush()

Package-level Flush function; for use by sklog package.

func Log

func Log(depth int, severity Severity, format string, args ...interface{})

Package-level Log function; for use by sklog package.

func LogMessageToString

func LogMessageToString(format string, args ...interface{}) string

LogMessageToString converts the last two params to Logger.Log to a string, as documented.

func SetLogger

func SetLogger(lg Logger)

SetLogger changes the package to use the given Logger.

func SetMetricsCallback

func SetMetricsCallback(metricsCallback MetricsCallback)

SetMetricsCallback sets sawLogWithSeverity.

This is set up to break a dependency cycle, such that sklog does not depend on metrics2.

Types

type Logger

type Logger interface {
	// Log sends a log message to a log destination. `depth` indicates the number
	// of stack frames to skip. (Implementations should call
	// `skerr.CallStack(2+depth, ...)`, assuming this call is in the Log method
	// itself, to skip the Log method and skerr.CallStack in addition to `depth`
	// frames.) `severity` is one of the severity constants.
	// This method handles both Print-like and Printf-like formatting; `format`
	// will be the empty string when Print-like formatting is desired.
	// To support composing Loggers, this method should not automatically die when
	// severity is Fatal.
	Log(depth int, severity Severity, format string, args ...interface{})

	// Flush sends any log messages that may be buffered or queued to the log
	// destination before returning.
	Flush()
}

Logger represents a log destination. All methods must be goroutine-safe. All methods must handle all errors, either by ignoring the errors or writing to os.Stderr.

type MetricsCallback

type MetricsCallback func(severity Severity)

metricsCallback should not call any sklog.* methods, to avoid infinite recursion.

type Severity

type Severity int

Severity identifies the sort of log: info, warning etc.

const (
	Debug Severity = iota
	Info
	Warning
	Error
	Fatal
)

These constants identify the log levels in order of increasing severity.

func AllSeverities

func AllSeverities() []Severity

AllSeverities returns a list of all severities understood by this package.

func (Severity) StackdriverString

func (s Severity) StackdriverString() string

StackdriverString returns the name of the severity per https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#LogSeverity

func (Severity) String

func (s Severity) String() string

String returns the full name of the Severity.

Jump to

Keyboard shortcuts

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