http_logger_config

package
v1.23.2 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultLogLevel = slog.LevelInfo

Variables

DefaultReplaceableMessages are the messages this module logs where what is worth reading about the request is in the HTTP context rather than in the message. The extractor that reads that context replaces them with what it says; see http_context_extractor_config.WithReplaceableMessages.

View Source
var DefaultWriter io.Writer = os.Stdout

DefaultWriter is where the entries go unless told otherwise. Standard output is where a process whose logs are collected for it is expected to write them.

Functions

This section is empty.

Types

type Config

type Config struct {
	Writer   io.Writer
	LogLevel slog.Level
	// HttpContextExtractor adds what is known about the request being logged. Unless one is set, an
	// extractor that replaces DefaultReplaceableMessages is.
	HttpContextExtractor *http_context_extractor.Extractor
	// Gcp makes the logger write what Google Cloud Logging expects of it: the names it reads the
	// severity and the message under, the fields it reads a request under, and entries within the
	// size it accepts. It is off by default, the rest being of no use to anything else.
	Gcp bool
	// GcpHttpContextExtractor adds what Cloud Logging reads a request under. Unless one is set, and
	// where Gcp is, a default one is.
	GcpHttpContextExtractor *gcpHttpContextExtractor.Extractor
}

func New

func New(options ...Option) *Config

type Option

type Option func(*Config)

func WithGcp

func WithGcp(gcp bool) Option

WithGcp makes the logger write what Google Cloud Logging expects of it, which nothing else reads.

func WithGcpHttpContextExtractor

func WithGcpHttpContextExtractor(gcpHttpContextExtractor *gcpHttpContextExtractor.Extractor) Option

WithGcpHttpContextExtractor sets what adds the fields Cloud Logging reads a request under. It is used only where WithGcp is.

func WithHttpContextExtractor

func WithHttpContextExtractor(httpContextExtractor *http_context_extractor.Extractor) Option

func WithLogLevel

func WithLogLevel(logLevel slog.Level) Option

func WithWriter

func WithWriter(writer io.Writer) Option

Jump to

Keyboard shortcuts

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