Documentation
¶
Index ¶
Constants ¶
const LOGSTORE_CAPACITY = 10000
Variables ¶
This section is empty.
Functions ¶
func InitLogLevel ¶
InitLogLevel initializes the global log level based on the provided string. Valid values are "debug", "info", "warn", "error", and "fatal
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
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 ¶
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