logx

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package logx fans fortressedge logs out to the places an edge operator can see them: the VGA console, the serial console, stderr, and — once the persistent disk is mounted — a log file under /var/log.

Real consoles keep a status panel pinned at the top. Log lines scroll underneath it. Kernel printk and foreign loggers do not write those consoles themselves; their lines are slog records, so one line cannot split another.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Active

func Active() bool

Active reports whether Setup has taken the consoles. Fatal messages use it so they scroll with the log instead of painting over the status panel.

func AddFile

func AddFile(dir string) error

AddFile tees the log into dir/current.log, keeping the previous boot as previous.log. Call once the persistent disk is mounted.

func BootID

func BootID() string

BootID is the kernel's per-boot UUID; ops log cursors are scoped to it.

func Forward

func Forward(src string) *lineForward

Forward returns a writer that turns another logger's lines into slog records. src is stored on each record. Bytes are held until a newline so a foreign logger cannot split a fortressedge line on the console.

func Rotated

func Rotated(dir string) []string

Rotated lists dir's *.log files other than current.log, newest first.

func SetConnections

func SetConnections(n func() int)

SetConnections names the source of the header's connection count: open TCP connections on 80 and 443. The header shows none until it is set.

func SetStatus

func SetStatus(st Status)

SetStatus pins the console grid. CPU and memory are sampled on each redraw and are not part of the logged snapshot.

func Setup

func Setup()

Setup installs the default slog logger on the fan-out and points it at the VGA and serial consoles. Call it after initos.Setup has mounted devtmpfs. PID 1's stderr is /dev/console, which already ends up on these consoles, so when at least one opens, stderr drops out to keep lines unduplicated; on dev runs (no consoles) stderr stays.

func Watch

func Watch(ctx context.Context)

Watch replays kernel errors that printk is no longer allowed to paint, then follows new ones. The status header refreshes until ctx ends.

func Writer

func Writer() io.Writer

Writer exposes the fan-out for text that is already whole lines, such as the last words before a power-off. Loggers use Forward or Zap instead.

func Zap

func Zap() *zap.Logger

Zap is a *zap.Logger for libraries that take one (certmagic and its ACME client). Every entry becomes a record on the default slog handler, so it reaches the consoles, the log file, and the ops logs API in the same format as ours. Call it after Setup.

Types

type AccessWriter added in v0.3.0

type AccessWriter interface {
	io.Writer
	// SetLimits changes the size at which a file rotates and the files
	// kept, from the next write; files past maxFiles go now.
	SetLimits(maxSize int64, maxFiles int)
}

AccessWriter is the access log's files.

func OpenAccess

func OpenAccess(dir string, maxSize int64, maxFiles int) (AccessWriter, error)

OpenAccess starts dir/current.log for the access log. It rotates at maxSize and keeps maxFiles files in all, the current one included, so the log never takes more than maxSize*maxFiles. Each file starts with the same marker as the edge's log, "# boot <id>", where the id is the boot id and, after a rotation, a sequence number; a rotated file is named <id>.log. The ops API's cursors name a file by its id.

Open it once per boot: a second one would start its files with the same ids.

type Status

type Status struct {
	Stage, Tunnel, ACME, QUIC, Disk, NTP string
	Iface, Addr, Gateway, DNS            string
	Frps, Listen, Blocked                string
	Ready, Connected                     bool
	Notes                                []string
}

Status is the pinned console grid. Ready and Connected are the only fields painted green or red. Notes are extra lines under the grid (why the edge cannot start) and stay in the default color.

Jump to

Keyboard shortcuts

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