Documentation
¶
Overview ¶
code_snippet.go
dev_tera_handler.go
formatter.go
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatCodeSnippet ¶ added in v0.5.0
func FormatCodeSnippet(filePath string, lineNumber int, level slog.Level, config CodeSnippetConfig) string
FormatCodeSnippet extracts and formats a code snippet from a file at the specified line
func NewDevelopment ¶
func NewDiscard ¶
func NewProduction ¶
Types ¶
type CodeSnippetConfig ¶ added in v0.5.0
type CodeSnippetConfig struct {
// Number of context lines to show before and after the target line
ContextLines int
// Styling options
ErrorLineStyle lipgloss.Style
DebugLineStyle lipgloss.Style
InfoLineStyle lipgloss.Style
WarnLineStyle lipgloss.Style
ContextLineStyle lipgloss.Style
LineNumberStyle lipgloss.Style
ErrorPointerStyle lipgloss.Style
// Text to show under different log levels
ErrorPointerText string
DebugPointerText string
InfoPointerText string
WarnPointerText string
}
CodeSnippetConfig holds configuration options for code snippet display
func DefaultCodeSnippetConfig ¶ added in v0.5.0
func DefaultCodeSnippetConfig() CodeSnippetConfig
DefaultCodeSnippetConfig returns the default configuration for code snippets
type DevHandler ¶
type DevHandler struct {
// contains filtered or unexported fields
}
type Formatter ¶ added in v0.5.0
type Formatter interface {
// Format returns a formatted byte slice for a given slog record.
Format(r slog.Record) ([]byte, error)
}
Formatter defines how to convert a slog.Record into styled output.
type TeraHandler ¶ added in v0.5.0
type TeraHandler struct {
// contains filtered or unexported fields
}
TeraHandler is a custom slog.Handler that formats log records with borders, colored text, and code snippets.
func NewTeraHandler ¶ added in v0.5.0
func NewTeraHandler(opts TeraOptions) *TeraHandler
NewTeraHandler creates a new TeraHandler using the provided options.
func (*TeraHandler) Handle ¶ added in v0.5.0
Handle formats the slog record in Tera style and writes it to stdout.
type TeraOptions ¶ added in v0.5.0
type TeraOptions struct {
HeaderTitle string // e.g. "Traceback (most recent call last)"
BorderColor lipgloss.Color // For header/footer borders.
PanelBorderColor lipgloss.Color // For attribute panel borders.
DateFormat string // e.g. time.RFC3339; if empty a default is used.
}
TeraOptions holds style options for the Tera handler.