Files
logwisp/internal/format/format.go
T
lixen 71d1b82f83
Test / test (push) Canceled after 0s
Test / e2e (push) Canceled after 0s
v0.22.0 several enhancements and fixes for security, network, doc, test, packaging
2026-10-03 14:52:16 -04:00

29 lines
706 B
Go

package format
import (
"logwisp/internal/config"
"logwisp/internal/core"
)
// Formatter defines the interface for transforming a LogEntry into a byte slice
type Formatter interface {
// Format takes a LogEntry and returns the formatted log as a byte slice
Format(entry core.LogEntry) ([]byte, error)
// Name returns the formatter's type name (e.g., "json", "raw")
Name() string
}
// NewFormatter creates a Formatter using formatter/sanitizer packages
func NewFormatter(cfg *config.FormatConfig) (Formatter, error) {
if cfg == nil {
cfg = &config.FormatConfig{
Type: DefaultFormatType,
Flags: 0,
SanitizerPolicy: "raw",
}
}
return NewFormatterAdapter(cfg)
}