Documentation
¶
Overview ¶
Package logging provides the host's structured, aggregated logger.
The host is the only component that touches log files: it writes its own JSON records and forwards each sidecar's stderr (via Writer) into one per-repo log file plus its own stderr. Services only write to stderr.
Index ¶
Constants ¶
const FileName = "anfra.log"
FileName is the log's file, in a repo's logs directory.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Logging ¶
type Logging struct {
Logger *slog.Logger
// App is the logger for what the repo's Data Apps report from the browser (appserve):
// the same stream as Logger, with "service":"app".
App *slog.Logger
StderrWriter io.Writer
StdoutWriter io.Writer
LogPath string
// contains filtered or unexported fields
}
Logging is the host's logging setup:
- Logger: the host's own structured logger (writes to anfra.log).
- StderrWriter: sink for forwarding sidecar stderr — the log stream, same destination as Logger (anfra.log; also host stderr when toStderr).
- StdoutWriter: sink for forwarding sidecar stdout — discarded by default (banners / incidental noise), or host stdout if ANFRA_SIDECAR_STDOUT.
func Setup ¶
Setup ensures logsDir exists, opens anfra.log there, and returns a host logger (and the same Writer the sidecars' output is forwarded into). The envelope ({ts, level, msg, service, repo, pid}) matches the Node sidecar's. Level comes from LOG_LEVEL (default info).
With toStderr, the log stream also goes to stderr: what `anfra serve` does unless ANFRA_LOG_STDERR=0, since a server's log is what its operator watches. Without, it goes only to the file, keeping a command's stderr for its error and warnings (ANFRA_LOG_STDERR=1 adds it, for debugging).