logging

package
v0.0.96 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: MIT Imports: 15 Imported by: 1

Documentation

Overview

Package logging provides logrus-backed adapters for the loggers prometheus libraries (and a few legacy shims) ask for.

Index

Constants

View Source
const ApacheFormatPattern = "%s - - [%s] \"%s %d %d\" %f %s\n"

Variables

View Source
var MaxFormPrefix = 256

Functions

func FormPrefix

func FormPrefix(form url.Values) string

func NewApacheLoggingHandler

func NewApacheLoggingHandler(handler http.Handler, logHandlers ...LogRecordHandler) http.Handler

func NewGoKitLogger added in v0.0.94

func NewGoKitLogger(logger logrus.FieldLogger) gokitlog.Logger

NewGoKitLogger returns a go-kit log.Logger that delegates to a logrus.FieldLogger. This is needed for the legacy glog-gokit and klog-gokit shims that are installed via go.mod replace directives — those still want a go-kit log.Logger, not an slog.Logger.

func NewLogger added in v0.0.60

func NewLogger(logger logrus.FieldLogger) *slog.Logger

NewLogger returns an *slog.Logger that delegates to a logrus.FieldLogger.

func SetMaxFormPrefix added in v0.0.69

func SetMaxFormPrefix(i int)

Types

type ApacheLogRecord

type ApacheLogRecord struct {
	http.ResponseWriter `json:"-"`

	IP            string    `json:"remoteAddr,omitempty"`
	Time          time.Time `json:"time,omitempty"`
	Method        string    `json:"method,omitempty"`
	URI           string    `json:"path,omitempty"`
	Protocol      string    `json:"protocol,omitempty"`
	Status        int       `json:"status,omitempty"`
	ResponseBytes int64     `json:"responseBytes,omitempty"`
	ElapsedTime   float64   `json:"duration,omitempty"`
	FormPrefix    string    `json:"query,omitempty"`
}

func (*ApacheLogRecord) Flush added in v0.0.96

func (r *ApacheLogRecord) Flush()

Flush forwards to the wrapped ResponseWriter when it supports flushing. Without this, streaming handlers (e.g. the notifications SSE endpoint) see the wrapper as a non-Flusher and bail out with "Streaming unsupported".

func (*ApacheLogRecord) Log

func (r *ApacheLogRecord) Log(out io.Writer)

func (*ApacheLogRecord) LogJson added in v0.0.61

func (r *ApacheLogRecord) LogJson(out io.Writer)

func (*ApacheLogRecord) Write

func (r *ApacheLogRecord) Write(p []byte) (int, error)

func (*ApacheLogRecord) WriteHeader

func (r *ApacheLogRecord) WriteHeader(status int)

type ApacheLoggingHandler

type ApacheLoggingHandler struct {
	// contains filtered or unexported fields
}

func (*ApacheLoggingHandler) ServeHTTP

func (h *ApacheLoggingHandler) ServeHTTP(rw http.ResponseWriter, r *http.Request)

type LogRecordHandler

type LogRecordHandler func(*ApacheLogRecord)

func LogJsonToWriter added in v0.0.61

func LogJsonToWriter(out io.Writer) LogRecordHandler

func LogToWriter

func LogToWriter(out io.Writer) LogRecordHandler

Jump to

Keyboard shortcuts

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