diff --git a/doc/logging-guide.md b/doc/logging-guide.md index 1eb4598..732dd1a 100644 --- a/doc/logging-guide.md +++ b/doc/logging-guide.md @@ -126,7 +126,7 @@ func logWithContext(ctx context.Context, logger *log.Logger, level string, msg s ## Output Formats -### Text Format (Human-Readable) +### Txt Format (Human-Readable) Default format for development and debugging: @@ -135,7 +135,7 @@ Default format for development and debugging: 2024-01-15T10:30:45.234567890Z WARN Rate limit approaching user_id=42 requests=95 limit=100 ``` -Note: The text format does not add quotes around string values containing spaces. This ensures predictability for simple, space-delimited parsing tools. For logs where maintaining the integrity of such values is critical, `json` format is recommended. +Note: The txt format does not add quotes around string values containing spaces. This ensures predictability for simple, space-delimited parsing tools. For logs where maintaining the integrity of such values is critical, `json` format is recommended. Configuration: ```go diff --git a/format.go b/format.go index 1771b28..79545bb 100644 --- a/format.go +++ b/format.go @@ -32,7 +32,7 @@ func (s *serializer) reset() { s.buf = s.buf[:0] } -// serialize converts log entries to the configured format, JSON, raw, or (default) text. +// serialize converts log entries to the configured format, JSON, raw, or (default) txt. func (s *serializer) serialize(format string, flags int64, timestamp time.Time, level int64, trace string, args []any) []byte { s.reset() @@ -54,7 +54,7 @@ func (s *serializer) serialize(format string, flags int64, timestamp time.Time, if format == "json" { return s.serializeJSON(flags, timestamp, level, trace, args) } - return s.serializeText(flags, timestamp, level, trace, args) + return s.serializeTxt(flags, timestamp, level, trace, args) } // serializeRaw formats args as space-separated strings without metadata or newline. @@ -177,8 +177,8 @@ func (s *serializer) serializeJSON(flags int64, timestamp time.Time, level int64 return s.buf } -// serializeText formats log entries as plain text (time, level, trace, fields). -func (s *serializer) serializeText(flags int64, timestamp time.Time, level int64, trace string, args []any) []byte { +// serializeTxt formats log entries as plain txt (time, level, trace, fields). +func (s *serializer) serializeTxt(flags int64, timestamp time.Time, level int64, trace string, args []any) []byte { needsSpace := false if flags&FlagShowTimestamp != 0 { @@ -206,7 +206,7 @@ func (s *serializer) serializeText(flags int64, timestamp time.Time, level int64 if needsSpace { s.buf = append(s.buf, ' ') } - s.writeTextValue(arg) + s.writeTxtValue(arg) needsSpace = true } @@ -214,8 +214,8 @@ func (s *serializer) serializeText(flags int64, timestamp time.Time, level int64 return s.buf } -// writeTextValue converts any value to its text representation. -func (s *serializer) writeTextValue(v any) { +// writeTxtValue converts any value to its txt representation. +func (s *serializer) writeTxtValue(v any) { switch val := v.(type) { case string: s.buf = append(s.buf, val...) diff --git a/format_test.go b/format_test.go index 8a6015f..fbe45b7 100644 --- a/format_test.go +++ b/format_test.go @@ -16,7 +16,7 @@ func TestSerializer(t *testing.T) { s := newSerializer() timestamp := time.Date(2024, 1, 1, 12, 0, 0, 0, time.UTC) - t.Run("text format", func(t *testing.T) { + t.Run("txt format", func(t *testing.T) { data := s.serialize("txt", FlagDefault, timestamp, LevelInfo, "", []any{"test message", 123}) str := string(data) diff --git a/logger_test.go b/logger_test.go index c9c4906..afd3ec9 100644 --- a/logger_test.go +++ b/logger_test.go @@ -179,7 +179,7 @@ func TestLoggerFormats(t *testing.T) { check func(t *testing.T, content string) }{ { - name: "text format", + name: "txt format", format: "txt", check: func(t *testing.T, content string) { assert.Contains(t, content, "INFO test message")