logging

package
v8.17.4 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package logging provides logging-related helpers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetGlobalContextLoggers

func GetGlobalContextLoggers(ctx context.Context) ldlog.Loggers

GetGlobalContextLoggers returns the Loggers associated with this HTTP request for Relay's global logging. If no such context information was added to the request, it returns disabled loggers.

func GlobalContextLoggersMiddleware

func GlobalContextLoggersMiddleware(loggers ldlog.Loggers) func(http.Handler) http.Handler

GlobalContextLoggersMiddleware attaches global logging context to each HTTP request.

func MakeDefaultLoggers

func MakeDefaultLoggers() ldlog.Loggers

MakeDefaultLoggers returns a Loggers instance configured with Relay's standard log format. Output goes to stdout, except Error level which goes to stderr. Debug level is disabled.

The log format is determined by the LOG_FORMAT environment variable:

  • "text" (default): traditional text-based log format with timestamps
  • "json": JSON-structured log output

func RequestLoggerMiddleware

func RequestLoggerMiddleware(loggers ldlog.Loggers) func(http.Handler) http.Handler

RequestLoggerMiddleware decorates a Handler with debug-level logging of all requests.

Types

type JSONLogEntry added in v8.17.0

type JSONLogEntry struct {
	Timestamp string `json:"timestamp"`
	Level     string `json:"level"`
	Message   string `json:"message"`
}

JSONLogEntry represents a structured log entry.

type JSONLogger added in v8.17.0

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

JSONLogger implements ldlog.BaseLogger and outputs JSON-structured logs.

func NewJSONLogger added in v8.17.0

func NewJSONLogger(w io.Writer) *JSONLogger

NewJSONLogger creates a new JSONLogger that writes to the given writer.

func (*JSONLogger) Printf added in v8.17.0

func (l *JSONLogger) Printf(format string, values ...interface{})

Printf implements ldlog.BaseLogger. It parses the level prefix from the format and outputs a JSON-structured log line.

func (*JSONLogger) Println added in v8.17.0

func (l *JSONLogger) Println(values ...interface{})

Println implements ldlog.BaseLogger. It parses the level prefix from the message and outputs a JSON-structured log line.

Jump to

Keyboard shortcuts

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