Documentation
¶
Overview ¶
Package logging provides structured logging for the Entire CLI using slog.
Usage:
// Initialize logger for a session (typically at session start)
if err := logging.Init(sessionID); err != nil {
// handle error
}
defer logging.Close()
// Add context values
ctx = logging.WithComponent(ctx, "hooks")
ctx = logging.WithAgent(ctx, agentName)
// Log with context - component/agent extracted automatically
logging.Info(ctx, "hook invoked",
slog.String("hook", hookName),
slog.String("branch", branch),
)
Index ¶
- Constants
- func Close()
- func Debug(ctx context.Context, msg string, attrs ...any)
- func Error(ctx context.Context, msg string, attrs ...any)
- func Info(ctx context.Context, msg string, attrs ...any)
- func Init(ctx context.Context, sessionID string) error
- func SetLogLevelGetter(getter func() string)
- func Warn(ctx context.Context, msg string, attrs ...any)
- func WithAgent(ctx context.Context, agentName types.AgentName) context.Context
- func WithComponent(ctx context.Context, component string) context.Context
Constants ¶
const LogLevelEnvVar = "ENTIRE_LOG_LEVEL"
LogLevelEnvVar is the environment variable that controls log level.
const LogsDir = ".entire/logs"
LogsDir is the directory where log files are stored (relative to repo root).
Variables ¶
This section is empty.
Functions ¶
func Close ¶
func Close()
Close closes the log file if one is open. Flushes any buffered data before closing. Safe to call multiple times.
func Init ¶
Init initializes the logger for a session, writing JSON logs to .entire/logs/entire.log.
If sessionID is non-empty, it is stored as an slog attribute on every log line for filtering. If the log file cannot be created, falls back to stderr. Log level is controlled by ENTIRE_LOG_LEVEL environment variable.
func SetLogLevelGetter ¶
func SetLogLevelGetter(getter func() string)
SetLogLevelGetter sets a callback function to get the log level from settings. This allows the logging package to read settings without a circular dependency. The callback is only used if ENTIRE_LOG_LEVEL env var is not set.
Types ¶
This section is empty.