feat(diary): channels, components and config/log.yaml

- stderr and null drivers; per-component levels from log.components
- SUMMER_LOG__ overrides parse as strings and overlay the defaults key by key
- Validation names the key: driver, format, level, days, stack children and cycles, daily path outside the root
- summer new writes config/log.yaml (stack of console and daily, river warn, http info)
- docs/services/logging.md: channels, config/log.yaml, component loggers, daily files, redaction
- Log keys in the configuration docs; ExampleFor backs the docs snippet
This commit is contained in:
Jakub Zych
2026-10-21 11:48:25 +02:00
parent e903cc32be
commit 5b09b32512
16 changed files with 445 additions and 43 deletions

View File

@@ -389,6 +389,7 @@ func planNewApp(opts NewOptions, target, framework string) ([]genFile, error) {
{"config/database.yaml", "new/config/database.yaml", 0o644},
{"config/http.yaml", "new/config/http.yaml", 0o644},
{"config/storage.yaml", "new/config/storage.yaml", 0o644},
{"config/log.yaml", "new/config/log.yaml", 0o644},
{".env", "new/env", 0o600},
{".env.example", "new/env.example", 0o644},
{"compose.yaml", "new/compose.yaml", 0o644},

View File

@@ -133,7 +133,7 @@ func TestNewGolden(t *testing.T) {
dir, out := newGoldenApp(t, false)
for _, rel := range []string{
"go.mod", "go.work", "summer.yaml", "main.go", "plugins.gen.go",
"config/app.yaml", "config/database.yaml", "config/http.yaml", "config/storage.yaml",
"config/app.yaml", "config/database.yaml", "config/http.yaml", "config/storage.yaml", "config/log.yaml",
".env", ".env.example", ".gitignore", "compose.yaml", "CLAUDE.md",
"plugins/demo/plugin.go", "plugins/demo/routes.go",
} {

View File

@@ -34,6 +34,34 @@ uploads:
public_path_prefix: "/storage/uploads"
{{end}}
{{define "new/config/log.yaml"}}# Logging, shaped like Laravel's config/logging.php: records go to the
# default channel, and a stack sends them to several channels at once.
# Override any key with a SUMMER_LOG__ variable, a double underscore
# separating path segments: SUMMER_LOG__CHANNELS__DAILY__DAYS=30.
default: stack
level: info
channels:
stack:
driver: stack
channels: [console, daily]
console:
# auto: styled lines on a terminal, logfmt otherwise (systemd, Docker);
# json writes JSON lines instead.
driver: console
format: auto
daily:
# One file per day under storage/logs (summer-YYYY-MM-DD.log), kept 14 days.
driver: daily
path: storage/logs/summer.log
days: 14
format: json
level: warn
components:
# Per-component levels. http: warn silences the request log.
river: warn
http: info
{{end}}
{{define "new/env"}}# Local secrets for this application: the database DSN, the application key
# and the admin token secret. .gitignore excludes this file; never commit it.
# Real environment variables override the values here.
@@ -123,7 +151,7 @@ summer admin:create --email you@example.com --superuser # create a backend admi
- `summer.yaml`: the application manifest (module path, binary name, ordered plugin list).
- `plugins/`: local plugin modules.{{if not .NoPlugin}} `plugins/{{.Name}}` is the starter plugin `golem15.{{.Name}}`; its `routes.go` answers `GET /` with JSON.{{end}}
- `config/`: YAML configuration (`app.yaml`, `database.yaml`, `http.yaml`, `storage.yaml`). Any key can be overridden with a `SUMMER_` environment variable, a double underscore separating path segments (`SUMMER_DATABASE__DSN` sets `database.dsn`).
- `config/`: YAML configuration (`app.yaml`, `database.yaml`, `http.yaml`, `log.yaml`, `storage.yaml`). Any key can be overridden with a `SUMMER_` environment variable, a double underscore separating path segments (`SUMMER_DATABASE__DSN` sets `database.dsn`).
- `.env`: local secrets (database DSN, application key, admin token secret). Never commit it; `.gitignore` excludes it. `.env.example` lists the variables.
- `compose.yaml`: the local PostgreSQL 16.
- `main.go`, `plugins.gen.go`: generated by `summer build` from `summer.yaml`. Do not edit them by hand; they are committed.

View File

@@ -31,7 +31,7 @@ summer admin:create --email you@example.com --superuser # create a backend admi
- `summer.yaml`: the application manifest (module path, binary name, ordered plugin list).
- `plugins/`: local plugin modules.
- `config/`: YAML configuration (`app.yaml`, `database.yaml`, `http.yaml`, `storage.yaml`). Any key can be overridden with a `SUMMER_` environment variable, a double underscore separating path segments (`SUMMER_DATABASE__DSN` sets `database.dsn`).
- `config/`: YAML configuration (`app.yaml`, `database.yaml`, `http.yaml`, `log.yaml`, `storage.yaml`). Any key can be overridden with a `SUMMER_` environment variable, a double underscore separating path segments (`SUMMER_DATABASE__DSN` sets `database.dsn`).
- `.env`: local secrets (database DSN, application key, admin token secret). Never commit it; `.gitignore` excludes it. `.env.example` lists the variables.
- `compose.yaml`: the local PostgreSQL 16.
- `main.go`, `plugins.gen.go`: generated by `summer build` from `summer.yaml`. Do not edit them by hand; they are committed.

View File

@@ -31,7 +31,7 @@ summer admin:create --email you@example.com --superuser # create a backend admi
- `summer.yaml`: the application manifest (module path, binary name, ordered plugin list).
- `plugins/`: local plugin modules. `plugins/demo` is the starter plugin `golem15.demo`; its `routes.go` answers `GET /` with JSON.
- `config/`: YAML configuration (`app.yaml`, `database.yaml`, `http.yaml`, `storage.yaml`). Any key can be overridden with a `SUMMER_` environment variable, a double underscore separating path segments (`SUMMER_DATABASE__DSN` sets `database.dsn`).
- `config/`: YAML configuration (`app.yaml`, `database.yaml`, `http.yaml`, `log.yaml`, `storage.yaml`). Any key can be overridden with a `SUMMER_` environment variable, a double underscore separating path segments (`SUMMER_DATABASE__DSN` sets `database.dsn`).
- `.env`: local secrets (database DSN, application key, admin token secret). Never commit it; `.gitignore` excludes it. `.env.example` lists the variables.
- `compose.yaml`: the local PostgreSQL 16.
- `main.go`, `plugins.gen.go`: generated by `summer build` from `summer.yaml`. Do not edit them by hand; they are committed.

View File

@@ -0,0 +1,26 @@
# Logging, shaped like Laravel's config/logging.php: records go to the
# default channel, and a stack sends them to several channels at once.
# Override any key with a SUMMER_LOG__ variable, a double underscore
# separating path segments: SUMMER_LOG__CHANNELS__DAILY__DAYS=30.
default: stack
level: info
channels:
stack:
driver: stack
channels: [console, daily]
console:
# auto: styled lines on a terminal, logfmt otherwise (systemd, Docker);
# json writes JSON lines instead.
driver: console
format: auto
daily:
# One file per day under storage/logs (summer-YYYY-MM-DD.log), kept 14 days.
driver: daily
path: storage/logs/summer.log
days: 14
format: json
level: warn
components:
# Per-component levels. http: warn silences the request log.
river: warn
http: info