actionlog

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionType

type ActionType string

ActionType classifies an action log entry.

const (
	TypeTx       ActionType = "tx"
	TypeQuery    ActionType = "query"
	TypeWorkflow ActionType = "workflow"
	TypeProvider ActionType = "provider"
	TypeContext  ActionType = "context"
	TypeConsole  ActionType = "console"
	TypeError    ActionType = "error"
)

type Entry

type Entry struct {
	Timestamp  time.Time       `json:"ts"`
	Type       ActionType      `json:"type"`
	Action     string          `json:"action"`
	TxHash     string          `json:"tx_hash,omitempty"`
	Height     int64           `json:"height,omitempty"`
	GasUsed    int64           `json:"gas_used,omitempty"`
	ResultCode uint32          `json:"code,omitempty"`
	DSeq       uint64          `json:"dseq,omitempty"`
	GSeq       uint32          `json:"gseq,omitempty"`
	OSeq       uint32          `json:"oseq,omitempty"`
	Provider   string          `json:"provider,omitempty"`
	Account    string          `json:"account,omitempty"`
	Params     json.RawMessage `json:"params,omitempty"`
	DurationMs int64           `json:"duration_ms,omitempty"`
	WorkflowID string          `json:"workflow_id,omitempty"`
	Step       int             `json:"step,omitempty"`
	StepName   string          `json:"step_name,omitempty"`
	Error      string          `json:"error,omitempty"`
	Status     string          `json:"status,omitempty"`
}

Entry is a single action log record, serialized as one JSON line.

type Filter

type Filter struct {
	Type    ActionType
	Since   time.Time
	Limit   int
	DSeq    uint64
	Account string
}

Filter defines criteria for reading log entries.

type Logger

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

Logger is an append-only action log backed by a JSONL file. It is safe for concurrent use.

func Open

func Open(path string) (*Logger, error)

Open opens (or creates) an action log file at the given path.

func (*Logger) Close

func (l *Logger) Close() error

Close flushes and closes the log file.

func (*Logger) Export

func (l *Logger) Export(w io.Writer) error

Export writes all entries to the given writer as JSONL.

func (*Logger) Log

func (l *Logger) Log(entry Entry) error

Log appends an entry to the log. It automatically rotates if needed.

func (*Logger) Read

func (l *Logger) Read(filter Filter) ([]Entry, error)

Read reads entries from the log, most recent first, applying the filter.

Jump to

Keyboard shortcuts

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