auloggingapi

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2024 License: MIT Imports: 1 Imported by: 18

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContextAwareLoggingImplementation

type ContextAwareLoggingImplementation interface {
	// Trace logs using TRACE level (-1).
	Trace() LeveledLoggingImplementation

	// Debug logs using DEBUG level (0).
	Debug() LeveledLoggingImplementation

	// Info logs using INFO level (1).
	Info() LeveledLoggingImplementation

	// Warn logs using WARN level (2).
	Warn() LeveledLoggingImplementation

	// Error logs using ERROR level (3).
	Error() LeveledLoggingImplementation

	// Fatal logs using FATAL level (4) and exit the application.
	//
	// Note that once application startup is over, this is usually very bad practice.
	Fatal() LeveledLoggingImplementation

	// Panic logs using PANIC level (5), print a stack trace, and exit the application.
	//
	// Note that this is usually very bad practice.
	Panic() LeveledLoggingImplementation
}

type CtxHasLoggerFunc added in v0.4.0

type CtxHasLoggerFunc func(ctx context.Context) bool

CtxHasLoggerFunc is the type of a function that checks whether a context.Context contains a logger.

type LeveledLoggingImplementation

type LeveledLoggingImplementation interface {
	// WithErr adds an error to the log message and keeps going.
	//
	// This does not actually log anything, you need to follow it up by Print or Printf.
	WithErr(err error) LeveledLoggingImplementation

	// With adds an additional key-value-pair to the log message and keeps going.
	//
	// This does not actually log anything, you need to follow it up by Print or Printf.
	With(key string, value string) LeveledLoggingImplementation

	// Print finalizes the log entry and emits it, including all arguments in the message.
	Print(v ...interface{})

	// Printf finalizes the log entry and emits it, using a format string for the message.
	Printf(format string, v ...interface{})
}

type LogEventCallbackFunc added in v0.3.0

type LogEventCallbackFunc func(ctx context.Context, level string, message string, err error, additionalFields map[string]string)

LogEventCallbackFunc is the type of a callback function you can provide to receive a callback for every log event.

level is set to "TRACE", "DEBUG", "INFO", "WARN", "ERROR", "FATAL"

type LoggingImplementation

type LoggingImplementation interface {
	// Ctx returns a context aware logger.
	//
	// You should use this if you have a context.
	//
	// Behaviour is implementation dependent, usually the logger will be taken from the context.
	Ctx(ctx context.Context) ContextAwareLoggingImplementation

	// NoCtx returns a context aware logger using a blank context.
	//
	// Use this if you do not have a context (but if it's your own code, you really should).
	NoCtx() ContextAwareLoggingImplementation
}

LoggingImplementation is the top level entry point to our logging API.

Note: access to the singleton instance is provided in the Logger global variable.

See convenience.go for some examples of how to use these interfaces.

type RequestIdRetrieverFunc added in v0.1.1

type RequestIdRetrieverFunc func(ctx context.Context) string

RequestIdRetrieverFunc is the type of a function used to obtain a request id from a context

Note: access to the singleton instance is provided in the Logger global variable.

used for tracing integration

Jump to

Keyboard shortcuts

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