logging

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package logging provides utility and helper functions and structs related to logging activity for both internal logs (regarding the centian proxy) and MCP requests/respoonses.

Index

Constants

This section is empty.

Variables

View Source
var ErrLogsDirNotFound = errors.New("centian logs directory not found")

ErrLogsDirNotFound is returned when the Centian logs directory is missing.

View Source
var ErrNoLogEntries = errors.New("no log entries found")

ErrNoLogEntries is returned when log files exist but contain no valid entries.

Functions

func FormatDisplayLine

func FormatDisplayLine(entry *AnnotatedLogEntry) string

FormatDisplayLine converts an AnnotatedLogEntry into a human-readable summary string.

func GetDefaultEventStorePath added in v0.2.0

func GetDefaultEventStorePath() (string, error)

GetDefaultEventStorePath returns the default SQLite path for durable event storage.

func GetLogsDirectory

func GetLogsDirectory() (string, error)

GetLogsDirectory returns the directory where Centian stores log files. Tests can override this path by setting the CENTIAN_LOG_DIR environment variable.

Types

type ActionEventStore added in v0.2.0

type ActionEventStore interface {
	AppendActionEvent(entry *common.LogEntry) error
}

ActionEventStore persists MCP action events in a queryable store.

type AnnotatedLogEntry

type AnnotatedLogEntry struct {
	Event      common.LogEntry
	SourceFile string
}

AnnotatedLogEntry wraps a generic MCP event with contextual metadata used for display.

func LoadRecentLogEntries

func LoadRecentLogEntries(limit int) ([]AnnotatedLogEntry, error)

LoadRecentLogEntries collects log entries from Centian log files, orders them by timestamp descending, and enforces an optional limit. A non-positive limit returns all available entries.

type Logger

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

Logger handles log file I/O operations (base logger for all transports).

func NewDiscardLogger added in v0.4.3

func NewDiscardLogger() (*Logger, error)

NewDiscardLogger creates a logger that skips JSONL writes while still allowing action event persistence through SetActionEventStore.

func NewLogger

func NewLogger() (*Logger, error)

NewLogger creates a new base logger instance.

func NewLoggerInDir added in v0.4.3

func NewLoggerInDir(logsDir string) (*Logger, error)

NewLoggerInDir creates a logger that writes request JSONL files in logDir.

func (*Logger) Close

func (l *Logger) Close() error

Close closes the logger.

func (*Logger) GetLogPath

func (l *Logger) GetLogPath() string

GetLogPath returns the absolute path to the current log file. This method can be used by external callers to:.

  • Display log location to users for debugging.
  • Access logs programmatically for analysis or monitoring.
  • Integrate with external log aggregation tools.
  • Provide log file paths in status/diagnostic outputs.

func (*Logger) LogEntry added in v0.0.3

func (l *Logger) LogEntry(entry interface{}) error

LogEntry writes any log entry to the JSONL file (base Logger method).

func (*Logger) LogMcpEvent

func (l *Logger) LogMcpEvent(event *common.LogEntry) error

LogMcpEvent logs the provided stdio/http MCP event.

func (*Logger) SetActionEventStore added in v0.2.0

func (l *Logger) SetActionEventStore(store ActionEventStore)

SetActionEventStore configures an optional SQL/event sink for MCP action events.

Jump to

Keyboard shortcuts

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