eventlog

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package eventlog records alarms, user actions and system events into a SQLite table and answers time-range queries, backing FameView's 事件记录 (event/audit log) screen with a persisted, filterable history.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	TS      time.Time
	Kind    Kind
	Source  string
	Message string
}

Event is one recorded log entry: when it happened, its kind, the component that emitted it, and a human-readable message.

type Kind

type Kind string

Kind classifies an event by what produced it.

const (
	KindAlarm  Kind = "alarm"  // a threshold/condition alarm fired
	KindLogin  Kind = "login"  // a user authentication event
	KindWrite  Kind = "write"  // an operator/system write to a tag or value
	KindSystem Kind = "system" // a system lifecycle or internal event
)

type Log

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

Log owns a SQLite handle holding a single events table.

func NewLog

func NewLog(dbPath string) (*Log, error)

NewLog opens (creating if needed) the SQLite database at dbPath and makes sure the events table and its ts and kind indexes exist.

func (*Log) Close

func (l *Log) Close() error

Close releases the underlying database handle.

func (*Log) Query

func (l *Log) Query(from, to time.Time, kinds ...Kind) ([]Event, error)

Query returns events whose timestamp is in [from, to] inclusive, ordered by timestamp ascending. When one or more kinds are given, only events of those kinds are returned; with no kinds, every kind is included.

func (*Log) Record

func (l *Log) Record(kind Kind, source, message string) error

Record appends one event stamped with the current wall-clock time. It is safe to call from any goroutine: writes serialise through the single-connection database/sql pool.

Jump to

Keyboard shortcuts

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