Log fx through slog, snake_case health check keys (closes #27)
check / check (push) Successful in 3m40s

fx wrote its own steps of starting and stopping as plain text to
stderr. It now logs them with its own slog event logger through the
backend's logger, so off a terminal every line from start to stop is
JSON. A config file that is found but cannot be read now makes
config.New return the error instead of panicking. A test runs the
server as a child process and checks that all it writes is JSON, on a
normal start and stop and with such a config file. The backend logs
its name, version and architecture once at start.

The health check's uptime keys are now uptime_seconds and
uptime_human, and its type and method take the names
GO_HTTP_SERVER_CONVENTIONS.md gives. Its path, content type, status
and code are unchanged.

Model: opus-5-5
This commit is contained in:
2026-10-03 23:59:50 +00:00
parent 924527b744
commit 5d0ae5989e
7 changed files with 251 additions and 21 deletions
+4 -3
View File
@@ -73,7 +73,8 @@ type Config struct {
// New loads configuration from env, .env files, and config
// files, returning a fully resolved Config. It fails, with an error
// naming the setting, on a value the server cannot use.
// naming the setting, on a value the server cannot use, and on a
// config file it finds but cannot read.
func New(
_ fx.Lifecycle,
params Params,
@@ -106,8 +107,8 @@ func New(
if err != nil {
var notFound viper.ConfigFileNotFoundError
if !errors.As(err, &notFound) {
log.Error("config file malformed", "error", err)
panic(err)
return nil, fmt.Errorf("config file %s: %w",
viper.ConfigFileUsed(), err)
}
}