logging

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 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 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 AnnotatedLogEntry

type AnnotatedLogEntry struct {
	Event      common.MCPEvent
	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 NewLogger

func NewLogger() (*Logger, error)

NewLogger creates a new base logger instance.

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.MCPEvent) error

LogMcpEvent logs the provided stdio/http MCP event.

Jump to

Keyboard shortcuts

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