Logger Component¶
Logger is the smallest component in the system, but it has one of the widest effects. It is simple, but it decides the log format and log level that the rest of the runtime sees.
1. What it does¶
- reads the configured log level
- creates the
sloghandler - calls
slog.SetDefault(...)to replace the global default logger
That means Logger does not "provide a logger to others". It directly rewrites global logging behavior.
2. Why it must initialize early¶
Runtime and the other components indirectly obtain a logger through slog.Default(). If Logger has not initialized first, the system falls back to Go's default logger behavior and log formatting becomes inconsistent.
3. Example config¶
type: logger
spec:
level: "info"
Currently supported levels:
debuginfowarnerror
4. Implementation highlights¶
- factory:
component/logger/factory.go - config:
component/logger/config.go - component:
component/logger/component.go
The path is straightforward:
- the factory decodes YAML
specintoLoggerSpec Validate()checks whetherlevelis validInit()creates the handler for the level and sets it as the default logger
5. Component boundary¶
Logger currently only owns the log output entry. It does not handle:
- log persistence
- log rotation
- trace correlation
- metrics emission
- per-request field injection
If the project later needs structured JSON logs, file output, or remote log collection, extend the Logger component instead of building separate logging logic inside each business component.
6. Current limitations¶
- The config surface is still small, mostly just
level. - More complex handler selection has not been abstracted yet.
- Request-level fields such as
request_idandsession_idstill need to be attached by business code.