Documentation
¶
Overview ¶
Package logging provides structured logging for mycelicmemory.
This package wraps Go's log/slog package to provide consistent, structured logging across all mycelicmemory components.
Usage:
import "github.com/MycelicMemory/mycelicmemory/internal/logging"
// Initialize once at startup
logging.Init(logging.Config{
Level: "info",
Format: "json",
Output: "stderr",
})
// Get a logger for a component
log := logging.GetLogger("mcp")
// Log with context
log.Info("request received", "method", "tools/call", "tool", "store_memory")
log.Error("operation failed", "error", err, "memory_id", id)
Index ¶
- func Debug(msg string, args ...any)
- func Error(msg string, args ...any)
- func Info(msg string, args ...any)
- func Init(cfg Config)
- func Warn(msg string, args ...any)
- type Config
- type Logger
- func (l *Logger) Debug(msg string, args ...any)
- func (l *Logger) Error(msg string, args ...any)
- func (l *Logger) Info(msg string, args ...any)
- func (l *Logger) LogError(operation string, err error, args ...any)
- func (l *Logger) LogOperation(operation string, args ...any)
- func (l *Logger) LogRequest(method string, args ...any)
- func (l *Logger) LogResponse(method string, duration float64, args ...any)
- func (l *Logger) Warn(msg string, args ...any)
- func (l *Logger) With(args ...any) *Logger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
// Level is the minimum log level: debug, info, warn, error
Level string
// Format is the output format: console, json
Format string
// Output is the output destination: stderr, stdout, or a file path
Output string
}
Config holds logging configuration
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger wraps slog.Logger with convenience methods
func GetLogger ¶
GetLogger returns a logger for the specified component. The component name is added as an attribute to all log entries.
func (*Logger) LogOperation ¶
LogOperation logs a successful operation
func (*Logger) LogRequest ¶
LogRequest logs an incoming request
func (*Logger) LogResponse ¶
LogResponse logs an outgoing response
Click to show internal directories.
Click to hide internal directories.