This commit is contained in:
kingecg 2025-06-06 20:23:06 +08:00
parent 107b8f3050
commit 1004333534
1 changed files with 6 additions and 3 deletions

View File

@ -10,11 +10,14 @@ import (
// LogFormatter is a function type that formats a LogEvent into a string.
// Example:
// formatter := func(event LogEvent) string {
// return fmt.Sprintf("[%s] %s: %v", event.Ts.Format("2006-01-02"), event.Level, event.Data)
// }
//
// formatter := func(event LogEvent) string {
// return fmt.Sprintf("[%s] %s: %v", event.Ts.Format("2006-01-02"), event.Level, event.Data)
// }
type LogFormatter = func(LogEvent) string
const logTemplate = "[%s] %s : %s - %s\n"
// format is the default formatter that converts a LogEvent to a string using the default template.
// It handles both simple values and formatted strings.
// Template: "[timestamp] level : category - data"