logging

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

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

View Source
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
	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

func Setup(logsDir, repo string, toStderr bool) (*Logging, error)

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

func (*Logging) Close

func (l *Logging) Close() error

Jump to

Keyboard shortcuts

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