logging

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: Apache-2.0 Imports: 6 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

This section is empty.

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 if ANFRA_LOG_STDERR).
  • 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) (*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).

By default logs go ONLY to the file, keeping the command's console output clean (results on stdout, command errors via cobra). Set ANFRA_LOG_STDERR=1 to also stream logs to stderr (useful for `anfra serve` / 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