Documentation
¶
Index ¶
- Variables
- func FallbackLogger() *slog.Logger
- func LogRequestFailed(ctx *executioncontext.ExecutionContext, code int, errorMessage string, ...)
- func LogRequestStarted(ctx *executioncontext.ExecutionContext, args ...any)
- func LogRequestSuccess(ctx *executioncontext.ExecutionContext, code int, response any)
- func LogWithCallerSkip(ctx context.Context, logger *slog.Logger, level slog.Level, skip int, ...)
- type ShutdownFunc
Constants ¶
This section is empty.
Variables ¶
var LogLevelKey = logLevelKeyType{}
LogLevelKey is a context key for overriding the log level of a request.
Functions ¶
func FallbackLogger ¶
func LogRequestFailed ¶
func LogRequestFailed(ctx *executioncontext.ExecutionContext, code int, errorMessage string, skip ...int)
func LogRequestStarted ¶
func LogRequestStarted(ctx *executioncontext.ExecutionContext, args ...any)
func LogRequestSuccess ¶
func LogRequestSuccess(ctx *executioncontext.ExecutionContext, code int, response any)
func LogWithCallerSkip ¶ added in v0.2.0
func LogWithCallerSkip(ctx context.Context, logger *slog.Logger, level slog.Level, skip int, msg string, args ...any)
LogWithCallerSkip logs a message at the given level with the given args, skipping the given number of callers the caller is the function that called this function plus one, i.e the function that called one of the Log* functions the skip is the number of callers to skip the msg is the message to log the args are the arguments to add to the message the logger is the logger to use the level is the level to log at
Types ¶
type ShutdownFunc ¶
type ShutdownFunc func() error
ShutdownFunc is a function that shuts down the logger the return is an error if the logger could not be shut down
func NewLogger ¶
func NewLogger() (*slog.Logger, ShutdownFunc, error)
NewLogger creates and returns a new structured logger using zap as the underlying logging implementation, wrapped with slog's interface. The logger is configured with production settings and ISO8601 time encoding for consistent log formatting.
Returns:
- *slog.Logger: A structured logger instance that can be used throughout the application
- error: An error if the logger could not be initialized