-
Notifications
You must be signed in to change notification settings - Fork 39
Open
Description
It would be great to have an adapter between githubactions.Action and slog.Handler. For example:
// SlogHandler returns [slog.Handler] for that Action.
//
// [slog.LevelDebug], [slog.LevelInfo], [slog.LevelWarn], and [slog.LevelError] severity levels
// are mapped to debug, notice, warning, and error messages, respectively.
//
// [slog.SourceKey] attribute is automatically converted to "file" and "line" fields.
func (c *Action) SlogHandler() slog.HandlerThe the caller could do something like
h := slog.NewTextHandler(os.Stderr, nil)
if os.Getenv("GITHUB_ACTIONS") == "true" {
h = githubactions.New().SlogHandler()
}
slog.SetDefault(slog.New(h))Metadata
Metadata
Assignees
Labels
No labels