svaroglog

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package svaroglog forwards Go application logs to Svarog.

Index

Constants

This section is empty.

Variables

View Source
var ErrAlreadyConfigured = errors.New("Svarog logging is already configured")

ErrAlreadyConfigured means another Setup still owns a client in this process.

Functions

func Setup

func Setup(lifetime context.Context, options ...Option) (func() error, error)

Setup configures global slog and standard log using SVAROG_CONN_STRING or an explicit WithConnectionString option. Defaults are INFO, an INFO text console on stderr, a best-effort queue of 1024 records or 16 MiB of encoded data, and a five-second drain. Use WithDropQueueCapacity(0) for blocking admission. Setup does not install signal handlers.

Canceling lifetime starts shutdown independently of blocked logging calls. The returned cleanup also starts shutdown, waits for its result, and is safe to call repeatedly or concurrently. Call it before exiting to observe drain errors. Drain uses a fresh context and confirms broker ACKs, not database persistence.

Only one Setup may be active. Cleanup restores the previous global logging state if the application still uses this setup's handler, including derivatives made with With/WithGroup. An independently replaced logger is left untouched. Applications should not reconfigure global logging concurrently with Setup or its cleanup.

Types

type Option

type Option func(*setupConfig) error

Option configures Setup. Defaults require only SVAROG_CONN_STRING.

func WithConnectionString

func WithConnectionString(value string) Option

WithConnectionString overrides SVAROG_CONN_STRING.

func WithConsole

func WithConsole(value slog.Handler) Option

WithConsole replaces the default INFO text handler on stderr. Nil disables it. Do not pass the initial slog.Default().Handler(), which can cause a log loop.

func WithDrainTimeout

func WithDrainTimeout(value time.Duration) Option

WithDrainTimeout sets a positive drain deadline. The default is five seconds.

func WithDropQueueCapacity

func WithDropQueueCapacity(capacity int) Option

WithDropQueueCapacity sets the best-effort queue size (1024 by default). A positive capacity up to 65536 drops records when the slot or 16 MiB byte limit is reached. Dropped records still reach the console if enabled. Zero selects a blocking 16-slot queue, which waits for space to accept records.

func WithInstanceID

func WithInstanceID(value string) Option

WithInstanceID overrides the client's environment/hostname instance default.

func WithLevel

func WithLevel(value slog.Leveler) Option

WithLevel sets the minimum level sent to Svarog. Nil means INFO. The console's level is configured separately through its handler.

Jump to

Keyboard shortcuts

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