Documentation
¶
Overview ¶
Package log provides structured logging with OpenTelemetry integration for Fish executable
Index ¶
- Constants
- func Initialize(config *Config) error
- func SetupOtelIntegration() error
- func WithFunc(pack, fun string) *slog.Logger
- type Config
- type ConsoleHandler
- func (h *ConsoleHandler) Enabled(_ context.Context, level slog.Level) bool
- func (h *ConsoleHandler) Handle(_ context.Context, r slog.Record) error
- func (h *ConsoleHandler) SetUseColor(useColor bool)
- func (h *ConsoleHandler) WithAttrs(attrs []slog.Attr) slog.Handler
- func (h *ConsoleHandler) WithGroup(name string) slog.Handler
- type Level
Constants ¶
View Source
const ( ColorReset = "\033[0m" ColorGray = "\033[90m" ColorRed = "\033[91m" ColorYellow = "\033[93m" ColorBlue = "\033[94m" ColorCyan = "\033[96m" ColorWhite = "\033[97m" ColorDim = "\033[2m" )
ANSI color codes
Variables ¶
This section is empty.
Functions ¶
func Initialize ¶ added in v0.9.0
Initialize sets up the global logger with the given configuration
func SetupOtelIntegration ¶ added in v0.9.0
func SetupOtelIntegration() error
SetupOtelIntegration sets up OpenTelemetry integration for logging This is called from the monitoring package when OpenTelemetry is initialized
Types ¶
type Config ¶ added in v0.9.0
type Config struct {
Level string `json:"level"` // Log level (debug, info, warn, error)
Format string `json:"format"` // Output format (console, json)
UseTimestamp bool `json:"use_timestamp"` // Include timestamp in logs
UseColor bool `json:"use_color"` // Use colors in console output
UseModule bool `json:"use_module"` // Include module information
UseCaller bool `json:"use_caller"` // Include caller information
OtelEnabled bool `json:"otel_enabled"` // Enable OpenTelemetry integration
}
Configuration
func DefaultConfig ¶ added in v0.9.0
func DefaultConfig() *Config
DefaultConfig returns default logging configuration
type ConsoleHandler ¶ added in v0.9.0
type ConsoleHandler struct {
// contains filtered or unexported fields
}
ConsoleHandler is a custom slog.Handler that formats logs for console output
func NewConsoleHandler ¶ added in v0.9.0
func NewConsoleHandler(w io.Writer, opts *slog.HandlerOptions) *ConsoleHandler
NewConsoleHandler creates a new ConsoleHandler
func (*ConsoleHandler) Enabled ¶ added in v0.9.0
Enabled reports whether the handler handles records at the given level
func (*ConsoleHandler) SetUseColor ¶ added in v0.9.0
func (h *ConsoleHandler) SetUseColor(useColor bool)
SetUseColor enables or disables color output
Click to show internal directories.
Click to hide internal directories.