You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(cmd/librarian): log errors with error level (#2754)
Log level Error were lost in main when calling `log.Fatal` instead of
`slog.Error`. Errors returned appear as `INFO` messages instead of
`ERROR`.
This was likely an oversight switching to slog as default logger. In
internal/librarian/librarian.go, the `setupLogger` function calls
[slog.SetDefault()](https://github.com/googleapis/librarian/blob/13bcf280d28167d2c23ca40b61abf5e27e62972a/internal/librarian/librarian.go#L40).
This tells the slog package to become the default logger for the entire
application. A side effect of this is that slog also intercepts any
output from the standard log package with no level info.
Also added a validation step in e2e test on failure case for generate,
to verify error is reported with Error level.
Test run below to verify now it correctly reports error:
```
╰─$ go run ./cmd/librarian generate -push
time=2025-11-03T12:56:21.109-05:00 level=INFO msg="Temporary working directory" dir=/tmp/librarian-4043056686
time=2025-11-03T12:56:21.110-05:00 level=INFO msg="repo not specified, using current working directory as repo root" path=/usr/local/google/home/zhumin/repos/librarian
time=2025-11-03T12:56:21.110-05:00 level=ERROR msg="librarian command failed" err="failed to validate config: no GitHub token supplied for push"
exit status 1
```
Fix#2686
0 commit comments