Skip to content
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

NewLayerContributor does not log expected logs #46

Closed
1 of 3 tasks
sambhav opened this issue Mar 9, 2021 · 5 comments
Closed
1 of 3 tasks

NewLayerContributor does not log expected logs #46

sambhav opened this issue Mar 9, 2021 · 5 comments
Labels
semver:major A change requiring a major version bump type:enhancement A general enhancement v2 Work for v2 release

Comments

@sambhav
Copy link

sambhav commented Mar 9, 2021

What happened?

NewLayerContributor does not accept a logger instance. As a result bard.Logger does not have a proper file descriptor to log to. As a result contributors created using this don't show proper logs during the build process around caching etc.

  • What were you attempting to do?
    Use NewLayerContributor
  • What did you expect to happen?
    See logs around it
  • What was the actual behavior? Please provide log output, if possible.
    No logs

Build Configuration

  • What platform (pack, kpack, tekton buildpacks plugin, etc.) are you
    using? Please include a version.
    pack and kpack
  • What buildpacks are you using? Please include versions.
    Internal
  • What builder are you using? If custom, can you provide the output from pack inspect-builder <builder>?

Checklist

  • I have included log output.
  • The log output includes an error message.
  • I have included steps for reproduction.
@sambhav
Copy link
Author

sambhav commented Mar 9, 2021

We should probably add an argument to the layer contributor with the logger or default it to some sane value like os.Stdout

@dmikusa
Copy link
Contributor

dmikusa commented Aug 16, 2021

The issue with changing the signature of NewLayerContributor is that it would break the API and we'd have to a major version bump of the library. It's something we could do, but I don't think it's something we want to do at this time.

It's a little annoying, but what we typically do when using this API is to just set the logger directly after.

	lc := NewLayerContributor(d.Name(), d.ExpectedMetadata, d.ExpectedTypes)
	lc.Logger = d.Logger

Probably the only thing I could see us addressing here in the short to medium-term would be adding a net new method, like NewLayerContributorWithLogger or NewLayerContributorWithDefaultLogger. If that would be of interest let me know. That would be easy to add.

@dmikusa dmikusa added semver:major A change requiring a major version bump type:enhancement A general enhancement labels Aug 16, 2021
@c0d1ngm0nk3y
Copy link
Contributor

Defaulting it to os.Stdout sounds reasonable to me. That alone should not break anyone, right?

Having some possibility to set the logger like WithLogger() or NewLayerContributorWithLogger might be nice, but since Logger is already public, there would not be a real benefit.

@dmikusa
Copy link
Contributor

dmikusa commented Aug 4, 2023

My issue with defaulting this to os.Stdout is that it changes the behavior. I know there are times where we intentionally suppress logging. If we change the default, it could alter some of this behavior.

I actually almost closed this issue out the other day because in libcnb v2 we removed the concept of layer contributors entirely. I do want to add them back in libpak v2, because I think they are valuable and it'll help Paketo with upgrading to v2, but at that point we can change the API and ensure that loggers are being passed around correctly. That's ultimately why I didn't close this out, cause I wanted to keep it open as a reminder of this use case.

@dmikusa dmikusa added the v2 Work for v2 release label Aug 4, 2023
@dmikusa
Copy link
Contributor

dmikusa commented Aug 31, 2023

I believe this should be addressed in #284

If you have a moment to look @samj1912, feedback appreciated.

@dmikusa dmikusa closed this as completed Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver:major A change requiring a major version bump type:enhancement A general enhancement v2 Work for v2 release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants