logutil

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package logutil configures the global slog logger to write structured logs to a file inside the .drift/ directory. It is primarily used by the watch daemon, which runs as a background process without a terminal and therefore cannot rely on stderr for diagnostics.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitFileLogger

func InitFileLogger(driftDir string) (io.Closer, error)

InitFileLogger configures the global slog logger to write to <driftDir>/logs/drift.log. The writer rotates the file when it exceeds logMaxSizeMB, keeping at most logMaxBackups rotated copies (drift.log.1, drift.log.2, …). History is therefore bounded but preserved across daemon restarts. The returned io.Closer must be closed by the caller when logging is no longer needed (e.g. on process exit via defer). If the logs directory does not exist, it is created.

The log level is read from the DRIFT_LOG_LEVEL environment variable (debug/info/warn/error, case-insensitive). When unset or unrecognized, it defaults to info.

After this call, all slog package-level functions (slog.Info, slog.Warn, slog.Error, …) write to the file instead of stderr.

Types

This section is empty.

Jump to

Keyboard shortcuts

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