Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` |

Expand Down
8 changes: 4 additions & 4 deletions seilog.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
}

Expand Down
2 changes: 1 addition & 1 deletion seilog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down