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 ¶
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.