-
Notifications
You must be signed in to change notification settings - Fork 129
Open
Description
Summary
compose-go currently logs internally via logrus with no public switch to:
- silence the output
- redirect it to another sink
- integrate with the host application’s structured logger
This proposal asks to make the logger pluggable (e.g. via a WithLogger
option) so that consumers can supply any backend (log/slog, Zap, Zerolog, logrus, etc).
I’m volunteering to do the implementation and open a PR once the maintainers are happy with the direction.
What I’m proposing
- Accept either a
*slog.Logger
or aslog.Handler
through a simple opt-in API:func WithLogger(l *slog.Logger) func WithHandler(h slog.Handler)
- Keep the current logrus instance as the default handler to preserve existing behavior.
- Users who rely on other backends can plug them through existing adapters:
Notes
cli.ProjectOptions
andloader.Options
are plain structs, so adding aLogger
/Handler
field is straightforward - the caller just sets it viaWithLogger
/WithHandler
.- Many helpers call the global log instance directly. This causes unavoidable side-effects. the cleanest fix would be to pass the logger explicitly as a parameter so every call-site controls its behaviour.
- If retaining the global instance is required (to avoid large surface changes) we could expose a top-level
SetLogger
that simply wrapsslog.SetDefault
, preserving today's pattern while still allowing replacement.
Please let me know if this would be of interest and, if so, what your thoughts on the implementation would be.
Metadata
Metadata
Assignees
Labels
No labels