logger

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const LOGSTORE_CAPACITY = 10000

Variables

This section is empty.

Functions

func InitLogLevel

func InitLogLevel(level string) error

InitLogLevel initializes the global log level based on the provided string. Valid values are "debug", "info", "warn", "error", and "fatal

func NewLogger

func NewLogger(component string) *zerolog.Logger

NewLogger creates a logger writing to stdout and the shared memory log store.

Types

type LogEntry added in v0.16.0

type LogEntry struct {
	ID        int64  `json:"id"`
	Timestamp string `json:"time"`
	Component string `json:"component"`
	Level     string `json:"level"`
	Message   string `json:"message"`
}

LogEntry represents a single log entry.

ID is a per-store, monotonically increasing sequence number assigned on write (starting at 1). Unlike a slice index it never shifts as older entries are evicted from the buffer, so it's safe to hold onto as a pagination cursor across calls.

func GetLogsBefore added in v0.16.0

func GetLogsBefore(beforeID int64, limit int, component, level string) ([]LogEntry, bool)

GetLogsBefore returns up to limit log entries with ID < beforeID, oldest matching entry first — the "before" half of cursor-based pagination: pass the ID of the oldest entry from the previous page back in as beforeID to load the page before it. beforeID <= 0 starts from the most recent entry (there is no valid entry ID 0, since IDs are assigned starting at 1, so it doubles as the "no cursor yet" sentinel for the first page). The returned bool reports whether older entries remain unscanned in the buffer, i.e. whether a further "load more" call could return anything.

func GetLogsSince

func GetLogsSince(sinceID int64, component, level string) ([]LogEntry, int64)

GetLogsSince returns log entries with ID > sinceID (in ID order), along with the highest entry ID currently in the store — pass that back in as sinceID on the next call to continue tailing without gaps or repeats, regardless of how many entries have since been evicted from the buffer. sinceID <= 0 returns every entry currently buffered.

type MemoryLogStore

type MemoryLogStore struct {
	// contains filtered or unexported fields
}

MemoryLogStore is an in-memory log store that implements io.Writer

func (*MemoryLogStore) Write

func (s *MemoryLogStore) Write(p []byte) (int, error)

Write implements the io.Writer interface for MemoryLogStore

Jump to

Keyboard shortcuts

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