Documentation
¶
Overview ¶
Package svaroglog forwards Go application logs to Svarog.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrAlreadyConfigured = errors.New("Svarog logging is already configured")
ErrAlreadyConfigured means another Setup still owns a client in this process.
Functions ¶
func Setup ¶
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 ¶
WithConnectionString overrides SVAROG_CONN_STRING.
func WithConsole ¶
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 ¶
WithDrainTimeout sets a positive drain deadline. The default is five seconds.
func WithDropQueueCapacity ¶
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 ¶
WithInstanceID overrides the client's environment/hostname instance default.