Documentation
¶
Overview ¶
Package debug provides helpers for debugging template rendering.
Index ¶
- func CreateDebugFuncMap(debugMode *DebugMode) template.FuncMap
- func SetConfig(config Config) error
- func SuggestTemplateErrors(err error, templatePath string) []string
- type Config
- type DebugContext
- func (dc *DebugContext) Complete()
- func (dc *DebugContext) CompleteWithError(err error)
- func (dc *DebugContext) Debug(msg string, args ...any)
- func (dc *DebugContext) Error(msg string, err error)
- func (dc *DebugContext) GetAttribute(key string) (any, bool)
- func (dc *DebugContext) Info(msg string, args ...any)
- func (dc *DebugContext) SetAttribute(key string, value any)
- type DebugLevel
- type DebugMode
- func (dm *DebugMode) Debug(msg string, args ...any)
- func (dm *DebugMode) Error(msg string, args ...any)
- func (dm *DebugMode) GetStats() DebugStats
- func (dm *DebugMode) Info(msg string, args ...any)
- func (dm *DebugMode) IsEnabled(level DebugLevel) bool
- func (dm *DebugMode) LogError(operation string, err error, context map[string]any)
- func (dm *DebugMode) LogFileWrite(path string, size int, duration time.Duration)
- func (dm *DebugMode) LogTemplateData(templatePath string, data any)
- func (dm *DebugMode) LogTemplateExecution(templatePath string, data any, duration time.Duration)
- func (dm *DebugMode) NewContext(operation string) *DebugContext
- func (dm *DebugMode) SetLevel(level DebugLevel) error
- func (dm *DebugMode) Trace(msg string, args ...any)
- func (dm *DebugMode) Warn(msg string, args ...any)
- type DebugOption
- type DebugStats
- type EnhancedError
- func (ee *EnhancedError) Error() string
- func (ee *EnhancedError) FormatDetailed() string
- func (ee *EnhancedError) GetContext() *ErrorContext
- func (ee *EnhancedError) Unwrap() error
- func (ee *EnhancedError) WithContext(key string, value any) *EnhancedError
- func (ee *EnhancedError) WithLine(line int) *EnhancedError
- func (ee *EnhancedError) WithOutput(path string) *EnhancedError
- func (ee *EnhancedError) WithSuggestion(suggestion string) *EnhancedError
- func (ee *EnhancedError) WithTemplate(path string) *EnhancedError
- type ErrorAnalyzer
- func (ea *ErrorAnalyzer) AddError(err *EnhancedError)
- func (ea *ErrorAnalyzer) Clear()
- func (ea *ErrorAnalyzer) GetErrors() []EnhancedError
- func (ea *ErrorAnalyzer) GetErrorsByOperation(operation string) []EnhancedError
- func (ea *ErrorAnalyzer) GetErrorsByTemplate(templatePath string) []EnhancedError
- func (ea *ErrorAnalyzer) GetStatistics() ErrorStatistics
- type ErrorContext
- type ErrorStatistics
- type StackFrame
- type TemplateDebugger
- func (td *TemplateDebugger) ClearExecutions()
- func (td *TemplateDebugger) ExecuteWithDebug(name string, tmpl *template.Template, data any) (string, error)
- func (td *TemplateDebugger) GetExecutionStats() map[string]any
- func (td *TemplateDebugger) GetExecutions() []TemplateExecution
- func (td *TemplateDebugger) RegisterTemplate(name string, tmpl *template.Template)
- type TemplateExecution
- type TemplateValidator
- type TimeRange
- type ValidationError
- type ValidationResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateDebugFuncMap ¶
func SuggestTemplateErrors ¶
Types ¶
type Config ¶
type Config struct {
MaxStackFrames int `json:"max_stack_frames"`
ErrorBufferSize int `json:"error_buffer_size"`
ExecutionBufferSize int `json:"execution_buffer_size"`
MaxStackTraceDisplay int `json:"max_stack_trace_display"`
}
func DefaultConfig ¶
func DefaultConfig() Config
type DebugContext ¶
type DebugContext struct {
// contains filtered or unexported fields
}
func (*DebugContext) Complete ¶
func (dc *DebugContext) Complete()
func (*DebugContext) CompleteWithError ¶
func (dc *DebugContext) CompleteWithError(err error)
func (*DebugContext) Debug ¶
func (dc *DebugContext) Debug(msg string, args ...any)
func (*DebugContext) Error ¶
func (dc *DebugContext) Error(msg string, err error)
func (*DebugContext) GetAttribute ¶
func (dc *DebugContext) GetAttribute(key string) (any, bool)
func (*DebugContext) Info ¶
func (dc *DebugContext) Info(msg string, args ...any)
func (*DebugContext) SetAttribute ¶
func (dc *DebugContext) SetAttribute(key string, value any)
type DebugLevel ¶
type DebugLevel int
const ( LevelOff DebugLevel = iota LevelError LevelWarn LevelInfo LevelDebug LevelTrace )
func (DebugLevel) String ¶
func (dl DebugLevel) String() string
type DebugMode ¶
type DebugMode struct {
// contains filtered or unexported fields
}
func NewDebugMode ¶
func NewDebugMode(opts ...DebugOption) *DebugMode
func (*DebugMode) GetStats ¶
func (dm *DebugMode) GetStats() DebugStats
func (*DebugMode) IsEnabled ¶
func (dm *DebugMode) IsEnabled(level DebugLevel) bool
func (*DebugMode) LogFileWrite ¶
func (*DebugMode) LogTemplateData ¶
func (*DebugMode) LogTemplateExecution ¶
func (*DebugMode) NewContext ¶
func (dm *DebugMode) NewContext(operation string) *DebugContext
func (*DebugMode) SetLevel ¶
func (dm *DebugMode) SetLevel(level DebugLevel) error
type DebugOption ¶
type DebugOption func(*DebugMode)
func WithLevel ¶
func WithLevel(level DebugLevel) DebugOption
func WithMetrics ¶
func WithMetrics(enable bool) DebugOption
func WithOutput ¶
func WithOutput(output io.Writer) DebugOption
func WithProfiling ¶
func WithProfiling(enable bool) DebugOption
func WithTracing ¶
func WithTracing(enable bool) DebugOption
type DebugStats ¶
type DebugStats struct {
Level DebugLevel `json:"level"`
StartTime time.Time `json:"start_time"`
Uptime time.Duration `json:"uptime"`
ProfilingEnabled bool `json:"profiling_enabled"`
TracingEnabled bool `json:"tracing_enabled"`
MetricsEnabled bool `json:"metrics_enabled"`
}
func (DebugStats) String ¶
func (ds DebugStats) String() string
type EnhancedError ¶
type EnhancedError struct {
// contains filtered or unexported fields
}
func NewEnhancedError ¶
func NewEnhancedError(err error, operation string) *EnhancedError
func (*EnhancedError) Error ¶
func (ee *EnhancedError) Error() string
func (*EnhancedError) FormatDetailed ¶
func (ee *EnhancedError) FormatDetailed() string
func (*EnhancedError) GetContext ¶
func (ee *EnhancedError) GetContext() *ErrorContext
func (*EnhancedError) Unwrap ¶
func (ee *EnhancedError) Unwrap() error
func (*EnhancedError) WithContext ¶
func (ee *EnhancedError) WithContext(key string, value any) *EnhancedError
func (*EnhancedError) WithLine ¶
func (ee *EnhancedError) WithLine(line int) *EnhancedError
func (*EnhancedError) WithOutput ¶
func (ee *EnhancedError) WithOutput(path string) *EnhancedError
func (*EnhancedError) WithSuggestion ¶
func (ee *EnhancedError) WithSuggestion(suggestion string) *EnhancedError
func (*EnhancedError) WithTemplate ¶
func (ee *EnhancedError) WithTemplate(path string) *EnhancedError
type ErrorAnalyzer ¶
type ErrorAnalyzer struct {
// contains filtered or unexported fields
}
func NewErrorAnalyzer ¶
func NewErrorAnalyzer() *ErrorAnalyzer
func (*ErrorAnalyzer) AddError ¶
func (ea *ErrorAnalyzer) AddError(err *EnhancedError)
func (*ErrorAnalyzer) Clear ¶
func (ea *ErrorAnalyzer) Clear()
func (*ErrorAnalyzer) GetErrors ¶
func (ea *ErrorAnalyzer) GetErrors() []EnhancedError
func (*ErrorAnalyzer) GetErrorsByOperation ¶
func (ea *ErrorAnalyzer) GetErrorsByOperation(operation string) []EnhancedError
func (*ErrorAnalyzer) GetErrorsByTemplate ¶
func (ea *ErrorAnalyzer) GetErrorsByTemplate(templatePath string) []EnhancedError
func (*ErrorAnalyzer) GetStatistics ¶
func (ea *ErrorAnalyzer) GetStatistics() ErrorStatistics
type ErrorContext ¶
type ErrorContext struct {
Operation string `json:"operation"`
TemplatePath string `json:"template_path,omitempty"`
OutputPath string `json:"output_path,omitempty"`
LineNumber int `json:"line_number,omitempty"`
Context map[string]any `json:"context,omitempty"`
Suggestions []string `json:"suggestions,omitempty"`
Timestamp time.Time `json:"timestamp"`
Stack []StackFrame `json:"stack,omitempty"`
}
type ErrorStatistics ¶
type ErrorStatistics struct {
TotalErrors int `json:"total_errors"`
OperationStats map[string]int `json:"operation_stats"`
TemplateStats map[string]int `json:"template_stats"`
TimeRange TimeRange `json:"time_range"`
}
func (ErrorStatistics) String ¶
func (es ErrorStatistics) String() string
type StackFrame ¶
type TemplateDebugger ¶
type TemplateDebugger struct {
// contains filtered or unexported fields
}
func NewTemplateDebugger ¶
func NewTemplateDebugger(debugMode *DebugMode) *TemplateDebugger
func (*TemplateDebugger) ClearExecutions ¶
func (td *TemplateDebugger) ClearExecutions()
func (*TemplateDebugger) ExecuteWithDebug ¶
func (*TemplateDebugger) GetExecutionStats ¶
func (td *TemplateDebugger) GetExecutionStats() map[string]any
func (*TemplateDebugger) GetExecutions ¶
func (td *TemplateDebugger) GetExecutions() []TemplateExecution
func (*TemplateDebugger) RegisterTemplate ¶
func (td *TemplateDebugger) RegisterTemplate(name string, tmpl *template.Template)
type TemplateExecution ¶
type TemplateValidator ¶
type TemplateValidator struct {
// contains filtered or unexported fields
}
func NewTemplateValidator ¶
func (*TemplateValidator) SetStrict ¶
func (tv *TemplateValidator) SetStrict(strict bool)
func (*TemplateValidator) ValidateDirectory ¶
func (tv *TemplateValidator) ValidateDirectory(templateDir string) map[string]ValidationResult
func (*TemplateValidator) ValidateTemplate ¶
func (tv *TemplateValidator) ValidateTemplate(templatePath string) ValidationResult
type ValidationError ¶
type ValidationResult ¶
type ValidationResult struct {
Valid bool `json:"valid"`
Errors []ValidationError `json:"errors"`
Warnings []ValidationError `json:"warnings"`
Info []string `json:"info"`
}
func (ValidationResult) HasErrors ¶
func (vr ValidationResult) HasErrors() bool
func (ValidationResult) Summary ¶
func (vr ValidationResult) Summary() string
Click to show internal directories.
Click to hide internal directories.