logging

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 16, 2025 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ComponentLevels = map[Component]LogLevel{}

ComponentLevels tracks the minimum log level for each component

View Source
var DefaultMinLevel = LevelInfo

DefaultMinLevel is the default minimum log level

View Source
var TestOutput io.Writer

TestOutput can be set during tests to capture log output

View Source
var Writer io.Writer = os.Stderr

Writer is the destination for logs

Functions

func ResetTestLogging

func ResetTestLogging()

ResetTestLogging resets logging after tests

func SetGlobalLevel

func SetGlobalLevel(level LogLevel)

SetGlobalLevel sets the log level for all components

func SetLevel

func SetLevel(component Component, level LogLevel)

SetLevel sets the minimum log level for a component

func SetWriter

func SetWriter(w io.Writer)

SetWriter sets the writer for log output

func SetupFileLogging

func SetupFileLogging(filePath string) error

SetupFileLogging configures logging to a file in addition to stderr

func SetupTestLogging

func SetupTestLogging(captureOutput io.Writer)

SetupTestLogging configures logging for tests

Types

type Component

type Component string

Component represents a specific part of the application for which logs can be filtered

const (
	// Core component for the main application
	Core Component = "core"
	// LSP component for high-level Language Server Protocol operations
	LSP Component = "lsp"
	// LSPWire component for raw LSP wire protocol messages
	LSPWire Component = "wire"
	// LSPProcess component for logs from the LSP server process itself
	LSPProcess Component = "lsp-process"
	// Watcher component for file system watching
	Watcher Component = "watcher"
	// Tools component for LSP tools
	Tools Component = "tools"
)

type ComponentLogger

type ComponentLogger struct {
	// contains filtered or unexported fields
}

ComponentLogger is a logger for a specific component

func (*ComponentLogger) Debug

func (l *ComponentLogger) Debug(format string, v ...any)

Debug logs a debug message

func (*ComponentLogger) Error

func (l *ComponentLogger) Error(format string, v ...any)

Error logs an error message

func (*ComponentLogger) Fatal

func (l *ComponentLogger) Fatal(format string, v ...any)

Fatal logs a fatal message and exits

func (*ComponentLogger) Info

func (l *ComponentLogger) Info(format string, v ...any)

Info logs an info message

func (*ComponentLogger) IsLevelEnabled

func (l *ComponentLogger) IsLevelEnabled(level LogLevel) bool

IsLevelEnabled returns true if the given log level is enabled for this component

func (*ComponentLogger) Warn

func (l *ComponentLogger) Warn(format string, v ...any)

Warn logs a warning message

type LogLevel

type LogLevel int

LogLevel represents the severity of a log message

const (
	// Debug level for verbose development logs
	LevelDebug LogLevel = iota
	// Info level for general operational information
	LevelInfo
	// Warn level for warning conditions
	LevelWarn
	// Error level for error conditions
	LevelError
	// Fatal level for critical errors
	LevelFatal
)

func (LogLevel) String

func (l LogLevel) String() string

String returns the string representation of a log level

type Logger

type Logger interface {
	Debug(format string, v ...any)
	Info(format string, v ...any)
	Warn(format string, v ...any)
	Error(format string, v ...any)
	Fatal(format string, v ...any)
	IsLevelEnabled(level LogLevel) bool
}

Logger is the interface for component-specific logging

func NewLogger

func NewLogger(component Component) Logger

NewLogger creates a new logger for the specified component

Jump to

Keyboard shortcuts

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