From 06c691c2cfb15898e9b13033cbf5fed40973df03 Mon Sep 17 00:00:00 2001 From: "Masih H. Derkani" Date: Thu, 12 Mar 2026 21:34:13 +0000 Subject: [PATCH] Change default format to text Change the default format to text in order to match the current default of seid to avoid larger code changes. --- README.md | 2 +- seilog.go | 8 ++++---- seilog_test.go | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 4b2034b..332aa2f 100644 --- a/README.md +++ b/README.md @@ -123,7 +123,7 @@ Output format, destination, and default level are configured at startup via envi | Variable | Values | Default | |---|---|---| | `SEI_LOG_LEVEL` | `debug`, `info`, `warn`, `error` | `info` | -| `SEI_LOG_FORMAT` | `json`, `text` | `json` | +| `SEI_LOG_FORMAT` | `json`, `text` | `text` | | `SEI_LOG_OUTPUT` | `stdout`, `stderr`, or an absolute file path | `stdout` | | `SEI_LOG_ADD_SOURCE` | `true`, `false` | `false` | diff --git a/seilog.go b/seilog.go index ff32ca5..a168139 100644 --- a/seilog.go +++ b/seilog.go @@ -85,7 +85,7 @@ // captured by each logger at creation time. // // SEI_LOG_LEVEL — Default level: debug, info, warn, error (default: info). -// SEI_LOG_FORMAT — Output format: json or text (default: json). +// SEI_LOG_FORMAT — Output format: json or text (default: text). // SEI_LOG_OUTPUT — Destination: stdout, stderr, or an absolute file path // (default: stdout). File paths must not contain ".." // components. Files are opened with mode 0600 and @@ -227,10 +227,10 @@ func newHandler(format string, w io.Writer) slog.Handler { Level: slog.Level(math.MinInt), // Handler accepts all; LevelVar filters } switch strings.ToLower(strings.TrimSpace(format)) { - case "text", "plain": - return slog.NewTextHandler(w, opts) - default: + case "json": return slog.NewJSONHandler(w, opts) + default: + return slog.NewTextHandler(w, opts) } } diff --git a/seilog_test.go b/seilog_test.go index 2382bac..59de555 100644 --- a/seilog_test.go +++ b/seilog_test.go @@ -602,7 +602,7 @@ func TestLevelFiltering_RuntimeChange(t *testing.T) { func TestOutput_JSONFormat(t *testing.T) { // Write to a temp file by setting env before creating a sub-process. // Since we can't re-init, we test by creating a logger and writing - // to the global handler (which defaults to JSON on stdout). + // to the global handler (which defaults to text on stdout). // We redirect via a pipe. // Use a temp file approach: create a logger, write, read back.