logging

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package logging provides the application's structured logger, built on the standard library's log/slog. It offers leveled, component-tagged, key=value logging with a compact human-readable text format (the default) or JSON.

Configuration is environment-driven and applied once via Setup:

STREMIO_LOG_LEVEL   debug | info | warn | error   (default: info)
STREMIO_LOG_FORMAT  text  | json                  (default: text)

Subsystems obtain a tagged logger with For("engine"), which stamps every record with component=engine so output can be filtered and read at a glance:

2026-06-27T12:00:37.700Z INFO  engine: disk piece cache  path=/var/cache size=0

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fatal

func Fatal(msg string, args ...any)

Fatal logs msg at error level with the given key=value args, then exits the process with status 1. It is the structured replacement for log.Fatalf.

func For

func For(component string) *slog.Logger

For returns a logger tagged with the given component name. The component is rendered as a leading "name:" by the text handler and as component=name by the JSON handler.

func Setup

func Setup()

Setup configures the process-wide slog default logger from the environment. It is safe to call once, early in startup, before any logging occurs.

Types

type ResponseRecorder

type ResponseRecorder struct {
	http.ResponseWriter
	Status int
	Bytes  int64
}

ResponseRecorder wraps an http.ResponseWriter to capture the response status code and the number of body bytes written, for access logging. It forwards Flush so streaming responses are unaffected, and exposes the underlying writer via Unwrap for any further interface probing.

func NewResponseRecorder

func NewResponseRecorder(w http.ResponseWriter) *ResponseRecorder

NewResponseRecorder wraps w. Status defaults to 200 if the handler writes a body without an explicit WriteHeader.

func (*ResponseRecorder) Flush

func (r *ResponseRecorder) Flush()

Flush forwards to the underlying writer when it supports http.Flusher; it is a no-op otherwise so callers can always rely on the method existing.

func (*ResponseRecorder) StatusOrOK

func (r *ResponseRecorder) StatusOrOK() int

StatusOrOK returns the recorded status, defaulting to 200 when the handler completed without ever writing a header or body.

func (*ResponseRecorder) Unwrap

func (r *ResponseRecorder) Unwrap() http.ResponseWriter

Unwrap returns the wrapped writer (used by http.ResponseController and tests).

func (*ResponseRecorder) Write

func (r *ResponseRecorder) Write(b []byte) (int, error)

func (*ResponseRecorder) WriteHeader

func (r *ResponseRecorder) WriteHeader(code int)

Jump to

Keyboard shortcuts

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