Help us shape the future of Go! Take the 2026 Go Developer Survey

logstore

package
v1.3.101 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package logstore pkg/visor/logstore/logstore.go c3-vis-core

Index

Constants

View Source
const DefaultHookLevel = logrus.InfoLevel

DefaultHookLevel is the most verbose level the hook returned by MakeStore accepts.

It is deliberately not logrus.AllLevels. Fire below takes a process-wide mutex, allocates a new Entry via entry.WithField, runs a full logrus.JSONFormatter.Format and copies the result into a string — for every entry the visor emits, on top of the formatting the logger already did for its own output. Measured on a production node running at debug, ~67k lines/min reach a hook like this one; the store holds 300 entries, so at that rate the buffer `cli visor log` and the hypervisor log viewer read back is a sub-second window, bought by serializing the whole visor's logging through one mutex and a second JSON encode.

The visor's default log level is info (skyenv.LogLevel), so info-and-above is exactly what those readers see today — this only keeps the hot debug and trace paths out of the formatter and off the mutex.

View Source
const LogRealLineKey = "log_line"

LogRealLineKey is a key in the log entry that denotes real log line number in the total log (not limited by capacity of runtime log store)

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

type Store interface {
	// GetLogs returns stored logs and the number of log entries overwritten
	// due to insufficient capacity.
	// returned number n means that n log entries have been dropped and the oldest
	// log entry is (n+1)th
	GetLogs() ([]string, int64)
	// GetLogsSince returns stored entries whose log_line is strictly
	// greater than since. The returned `dropped` is the number of
	// entries the caller missed because they aged out of the ring
	// buffer between calls (0 when the caller is keeping up). The
	// returned `latest` is the highest log_line currently in the
	// store — callers should pass it as `since` on the next call to
	// receive only newly-arrived entries (diff streaming).
	//
	// since == 0 returns the entire buffer (equivalent to GetLogs).
	// since >= latest returns an empty entry slice.
	GetLogsSince(since int64) (entries []string, dropped int64, latest int64)
}

Store is in-memory log store that returns all logs as a single string

func MakeStore

func MakeStore(maxx int) (Store, logrus.Hook)

MakeStore returns a new store that will hold up to max entries, overwriting the oldest entry when over the capacity returned hook should be registered in logrus master logger to store log entries. The hook accepts DefaultHookLevel and above; use MakeStoreLevel to capture more.

func MakeStoreLevel

func MakeStoreLevel(maxx int, level logrus.Level) (Store, logrus.Hook)

MakeStoreLevel is MakeStore with an explicit minimum severity for the returned hook: entries less severe than level never reach Fire, and so never pay the JSON encode or the store mutex.

Jump to

Keyboard shortcuts

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