log

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package log provides structured logging with OpenTelemetry integration for Fish executable

Index

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

func Initialize(config *Config) error

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

func WithFunc added in v0.9.0

func WithFunc(pack, fun string) *slog.Logger

WithFunc provides a way to identify package and function executed Empty values in the params are not allowed

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

func (h *ConsoleHandler) Enabled(_ context.Context, level slog.Level) bool

Enabled reports whether the handler handles records at the given level

func (*ConsoleHandler) Handle added in v0.9.0

func (h *ConsoleHandler) Handle(_ context.Context, r slog.Record) error

Handle handles the Record

func (*ConsoleHandler) SetUseColor added in v0.9.0

func (h *ConsoleHandler) SetUseColor(useColor bool)

SetUseColor enables or disables color output

func (*ConsoleHandler) WithAttrs added in v0.9.0

func (h *ConsoleHandler) WithAttrs(attrs []slog.Attr) slog.Handler

WithAttrs returns a new ConsoleHandler with the given attributes

func (*ConsoleHandler) WithGroup added in v0.9.0

func (h *ConsoleHandler) WithGroup(name string) slog.Handler

WithGroup returns a new ConsoleHandler with the given group

type Level added in v0.9.0

type Level = slog.Level
const (
	LevelDebug Level = slog.LevelDebug
	LevelInfo  Level = slog.LevelInfo
	LevelWarn  Level = slog.LevelWarn
	LevelError Level = slog.LevelError
)

func GetLevel added in v0.9.0

func GetLevel() Level

GetLevel returns current logging level as string

Jump to

Keyboard shortcuts

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