logging

package
v0.0.0-...-0fdad32 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddRequestLogger

func AddRequestLogger(ctx context.Context, baseLogger *slog.Logger) (context.Context, *slog.Logger)

AddRequestLogger adds a logger to this request. The logger will provide unique identification for any request in this stream (via the "ctx" field in the log). The logger can be retrieved via

func Fatal

func Fatal(logger *slog.Logger, msg string, keyvals ...interface{})

Fatal is an effective copy of go's log.Fatal, but using the logger provided, rather than using go's native logging. After writing the message, the code will exit with code 1

func GetSystemLogger

func GetSystemLogger() *slog.Logger

func LogWithoutAuth

func LogWithoutAuth(msg string, keyvals ...interface{})

func NewNopLogger

func NewNopLogger() *slog.Logger

NewNopLogger creates a logger that actually does not log. useful in situations where some logger is needed, but for whatever reason, a real logger is missing (or if you want to conditionally) disable logging.

func ReqLogger

func ReqLogger(ctx context.Context) *slog.Logger

ReqLogger retrieves a stored initially stored with AddRequestLogger. This logger is tied to the request (or more specifically, the context). Assuming you only have a request handy, the code to retrieve the logger is: logging.ReqLogger(r.Context())

func SetSystemLogger

func SetSystemLogger(logger *slog.Logger)

func SetupStdoutLogging

func SetupStdoutLogging() *slog.Logger

SetupStdoutLogging creates a new logger that logs to standard out

func SystemLog

func SystemLog(msg string, keyvals ...interface{})

SystemLog provides a system-level logger, which is not tied to any request. this should be used in situations where either a context is not handy, but logging is important or for events that are not tied to a request (e.g. losing database connection)

Types

This section is empty.

Jump to

Keyboard shortcuts

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