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 ¶
- func Active() bool
- func AddFile(dir string) error
- func BootID() string
- func Forward(src string) *lineForward
- func Rotated(dir string) []string
- func SetConnections(n func() int)
- func SetStatus(st Status)
- func Setup()
- func Watch(ctx context.Context)
- func Writer() io.Writer
- func Zap() *zap.Logger
- type AccessWriter
- type Status
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 ¶
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 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 ¶
Watch replays kernel errors that printk is no longer allowed to paint, then follows new ones. The status header refreshes until ctx ends.
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.