Files

46 lines
2.1 KiB
Go
Raw Permalink Normal View History

2025-08-08 09:32:04 +03:00
package tools
2025-11-12 16:48:46 +03:00
// DebugLogger defines the interface for debug logging in the MCP tools package.
// Implementations can provide different strategies for handling debug output,
// such as immediate console output, buffering, or file logging.
// All implementations must be thread-safe for concurrent use.
2025-08-08 09:32:04 +03:00
type DebugLogger interface {
2025-11-12 16:48:46 +03:00
// LogDebug logs a debug message. Implementations determine how the message is handled.
2025-08-08 09:32:04 +03:00
LogDebug(message string)
2025-11-12 16:48:46 +03:00
// IsDebugEnabled returns true if debug logging is enabled, allowing callers
// to skip expensive debug operations when debugging is disabled.
2025-08-08 09:32:04 +03:00
IsDebugEnabled() bool
}
2025-11-12 16:48:46 +03:00
// SimpleDebugLogger provides a minimal implementation of the DebugLogger interface.
// It is intentionally silent by default to prevent duplicate or unstyled debug output
// during initialization. Debug messages are only displayed when using the CLI debug logger
// which provides proper formatting and styling.
2025-08-08 09:32:04 +03:00
type SimpleDebugLogger struct {
enabled bool
}
2025-11-12 16:48:46 +03:00
// NewSimpleDebugLogger creates a new simple debug logger instance.
// The enabled parameter determines whether IsDebugEnabled will return true.
// Note that LogDebug is intentionally a no-op to avoid unstyled output;
// actual debug output is handled by the CLI's debug logger.
2025-08-08 09:32:04 +03:00
func NewSimpleDebugLogger(enabled bool) *SimpleDebugLogger {
return &SimpleDebugLogger{enabled: enabled}
}
2025-11-12 16:48:46 +03:00
// LogDebug is intentionally a no-op in SimpleDebugLogger.
// Debug messages are only displayed when using the CLI debug logger which provides
// proper formatting and styling. This prevents duplicate or unstyled debug output
// during initialization and ensures consistent debug output presentation.
2025-08-08 09:32:04 +03:00
func (l *SimpleDebugLogger) LogDebug(message string) {
// Silent by default - messages will only appear when using CLI debug logger
// This prevents duplicate or unstyled debug output during initialization
}
2025-11-12 16:48:46 +03:00
// IsDebugEnabled returns whether debug logging is enabled for this logger.
// This allows code to conditionally execute expensive debug operations
// only when debugging is active, improving performance in production.
2025-08-08 09:32:04 +03:00
func (l *SimpleDebugLogger) IsDebugEnabled() bool {
return l.enabled
}