-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose LeveledLogger's Writers #284
Conversation
I'm completely onboard with the intention of this change. I'm also wondering if we might be able to find an API that isn't so repetitive. I threw this together, but I'm not convinced that it isn't too clever by half. It would let us just keep the existing public API we have, but allow the functions to be used as logger := scribe.NewLogger(os.Stdout)
executable := pexec.NewExecutable("bundle")
err := executable.Execute(pexec.Execution{
Args: []string{"install"},
Stdout: logger.Action,
})
if err != nil {
panic(err)
}
// This would print the output from `bundle install` indented at the "Action" level. I like the simplicity of the API in @fg-j's implementation though. @paketo-buildpacks/tooling-maintainers, your thoughts? |
@ryanmoran I'm curious how your version changes the current syntax we have for "regular" logging, like
Currently on
Is this an intentional change? Or am I missing something? |
I find @fg-j's implementation a bit easier to follow and don't mind the repetitiveness in favour of readability, I think I prefer that. It makes things a bit easier for buildpack authors trying to understand packit |
That's not what happens. As you can see in these tests the existing behavior is maintained. Lines 29 to 32 in 7c82261
|
@ryanmoran I think that I am following the logic you have purposed but if you could walk through and the introduction of the |
The fact that this is requiring so much explanation and creating clear confusion makes me think that my assumptions were correct. This is too clever. It creates a pretty API at the expense of maintainability. I propose that we drop it from consideration. |
We discussed the topic of log streaming at a working group meeting and it resulted in a change to the Paketo Buildpacks Style Guide, which now states:
This captures the sentiment of buildpack maintainers that streaming logs is preferable as log as the resulting bulid output is readable overall.
So I've tweaked my approach in the dotnet-publish buildpack to simply stream the output of dotnet publish in all cases.
I chose to expose
scribe.Emitter.ActionWriter
so that the log output fromdotnet publish
appears in a format consistent with other buildpack output, without breaking the current log formatting abstraction. To achieve consistent formatting using the scribe.Writer directly, I'd need to dig into the implementation of scribe.Emitter.Action() to see how the logs are formatted. I think it's better to abstract log formatting away from buildpack authors as much as possible.