Documentation
¶
Overview ¶
Package logging provides logging-related helpers.
Index ¶
- func GetGlobalContextLoggers(ctx context.Context) ldlog.Loggers
- func GlobalContextLoggersMiddleware(loggers ldlog.Loggers) func(http.Handler) http.Handler
- func MakeDefaultLoggers() ldlog.Loggers
- func RequestLoggerMiddleware(loggers ldlog.Loggers) func(http.Handler) http.Handler
- type JSONLogEntry
- type JSONLogger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetGlobalContextLoggers ¶
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 ¶
GlobalContextLoggersMiddleware attaches global logging context to each HTTP request.
func MakeDefaultLoggers ¶
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
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.