Skip to content

feat!: log package for consistent output#2979

Merged
mdelapenya merged 21 commits intotestcontainers:mainfrom
KenxinKun:discussion-2977/extract-logging-to-internal-package
Feb 19, 2025
Merged

feat!: log package for consistent output#2979
mdelapenya merged 21 commits intotestcontainers:mainfrom
KenxinKun:discussion-2977/extract-logging-to-internal-package

Conversation

@KenxinKun
Copy link
Copy Markdown
Contributor

@KenxinKun KenxinKun commented Feb 7, 2025

What does this PR do?

Implements solution for #2977

Why is it important?

Prepares the codebase for moving the logger to a new client, moving the interface and implementations behind testcontainers/log. It also silences some of the identified leaking logs in the wait package.

How does it fix the issue?

  • Moves the Logger interface and implementations to its own package testcontainers/log
  • Adds methods to retrieve (log.Default()) or set (log.SetDefault(logger)) the default logger
  • Re-uses the default logger in the wait package which was using the standard log package previously and leaking logs to STDOUT

@KenxinKun KenxinKun requested a review from a team as a code owner February 7, 2025 11:02
@netlify
Copy link
Copy Markdown

netlify bot commented Feb 7, 2025

Deploy Preview for testcontainers-go ready!

Name Link
🔨 Latest commit 5678f9b
🔍 Latest deploy log https://app.netlify.com/sites/testcontainers-go/deploys/67b5c0b5c1e1be0008c0c4e2
😎 Deploy Preview https://deploy-preview-2979--testcontainers-go.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@KenxinKun KenxinKun force-pushed the discussion-2977/extract-logging-to-internal-package branch from ea96e68 to 7a7f9b0 Compare February 7, 2025 11:06
@KenxinKun KenxinKun force-pushed the discussion-2977/extract-logging-to-internal-package branch from 7a7f9b0 to cdb9520 Compare February 7, 2025 11:11
@KenxinKun KenxinKun changed the title Extract logging to internal package [feat] Extract logging to internal package Feb 7, 2025
@KenxinKun KenxinKun changed the title [feat] Extract logging to internal package [fix] Extract logging to internal package Feb 7, 2025
@KenxinKun KenxinKun changed the title [fix] Extract logging to internal package fix: Extract logging to internal package Feb 7, 2025
@KenxinKun KenxinKun changed the title fix: Extract logging to internal package fix: extract logging to internal package Feb 7, 2025
@KenxinKun KenxinKun changed the title fix: extract logging to internal package fix: extract logging to separate package Feb 7, 2025
@KenxinKun KenxinKun mentioned this pull request Feb 7, 2025
Copy link
Copy Markdown
Contributor

@stevenh stevenh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, just a few little bits.

stevenh
stevenh previously approved these changes Feb 7, 2025
Copy link
Copy Markdown
Contributor

@stevenh stevenh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes LGTM.

As this is a breaking change lets add the ! to title and footer as per https://www.conventionalcommits.org/en/v1.0.0/

As it is a fix, I would suggestion we capture the what in the title and then in expand with how / why in the description.

@KenxinKun KenxinKun changed the title fix: extract logging to separate package fix!: extract logging to separate package and reused default logger in wait package to avoid leaking logs directly to stdout Feb 7, 2025
@KenxinKun KenxinKun changed the title fix!: extract logging to separate package and reused default logger in wait package to avoid leaking logs directly to stdout fix(wait)!: stop logging debug messages to stdout Feb 7, 2025
Copy link
Copy Markdown
Contributor

@stevenh stevenh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a little fix for log capture in the wait tests.

Copy link
Copy Markdown
Member

@mdelapenya mdelapenya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a few comments, no blockers

Copy link
Copy Markdown
Contributor

@stevenh stevenh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a typo and the request from @mdelapenya about the default logger.

stevenh
stevenh previously approved these changes Feb 18, 2025
Copy link
Copy Markdown
Member

@mdelapenya mdelapenya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you so much for your work here. 🙇

@KenxinKun @stevenh I added df2324e to avoid having you working more in this. It's basically adding the new log package to one missing markdown file.

We are merging this PR when the CI passes 🚀

Cheers!

@mdelapenya mdelapenya self-assigned this Feb 19, 2025
@mdelapenya
Copy link
Copy Markdown
Member

BTW @KenxinKun @stevenh wdyt if we change the title of this PR to communicate better we are refactoring the log infra? Something like feat(log)!: add log package to stop logging debug messages to stdout, but open to any suggestion 🙏

@stevenh
Copy link
Copy Markdown
Contributor

stevenh commented Feb 19, 2025

BTW @KenxinKun @stevenh wdyt if we change the title of this PR to communicate better we are refactoring the log infra? Something like feat(log)!: add log package to stop logging debug messages to stdout, but open to any suggestion 🙏

As this is a new package, I'd go with:
feat!: log package for consistent output

And then expand on the body.

The reason to not include log in the scope is it doesn't exist yet (updates would), and for description if it wraps in github its too long, so trying to be concise 😄

@KenxinKun
Copy link
Copy Markdown
Contributor Author

@mdelapenya @stevenh I synced the fork and update this branch you may need to kick CI again, happy with suggestions above

@KenxinKun KenxinKun changed the title fix(wait)!: stop logging debug messages to stdout fix(wait)!: log package for consistent output Feb 19, 2025
@mdelapenya mdelapenya changed the title fix(wait)!: log package for consistent output feat!: log package for consistent output Feb 19, 2025
@mdelapenya mdelapenya added feature New functionality or new behaviors on the existing one breaking change Causing compatibility issues. labels Feb 19, 2025
@mdelapenya mdelapenya merged commit a915813 into testcontainers:main Feb 19, 2025
180 checks passed
mdelapenya added a commit to mdelapenya/testcontainers-go that referenced this pull request Feb 20, 2025
* main: (54 commits)
  deps: update go version from 1.22.0 to 1.23.0 (testcontainers#2985)
  feat(redpanda): add bootstrap user account option (testcontainers#2975)
  chore(ollama): bump default version to 0.5.7 (testcontainers#2966)
  feat!: log package for consistent output (testcontainers#2979)
  docs: remove duplicated options in the customisers lists (testcontainers#2989)
  chore: exclude "modules/k6" from the build (testcontainers#2987)
  chore: enable var-naming from revive (private vars only) (testcontainers#2978)
  chore(deps): bump actions/checkout from 4.1.7 to 4.2.2 (testcontainers#2971)
  chore(deps): bump release-drafter/release-drafter from 6.0.0 to 6.1.0 (testcontainers#2970)
  chore!: remove variadic arguments from nats ConnectionString (testcontainers#2967)
  fix(ci): use same condition for sonar steps (testcontainers#2974)
  fix: return unique modified modules (testcontainers#2973)
  chore(deps): bump golangci/golangci-lint-action from 6.2.0 to 6.3.0 (testcontainers#2969)
  chore(ci): run lint in a separate build before running the tests (testcontainers#2876)
  fix(deps): update to github.com/shirou/gopsutil/v4 (testcontainers#2964)
  fix(valkey): fix port race (testcontainers#2962)
  chore(deps): bump golang.org/x/net in /modules/pinecone (testcontainers#2963)
  chore(deps): bump golang.org/x/net from 0.26.0 to 0.33.0 (testcontainers#2961)
  deps(fix): include modulegen templates dir in dependabot updates (testcontainers#2956)
  chore(deps): bump docker/setup-docker-action from 4.0.0 to 4.1.0 (testcontainers#2959)
  ...
mdelapenya added a commit to mdelapenya/testcontainers-go that referenced this pull request Feb 20, 2025
* main: (34 commits)
  deps: update go version from 1.22.0 to 1.23.0 (testcontainers#2985)
  feat(redpanda): add bootstrap user account option (testcontainers#2975)
  chore(ollama): bump default version to 0.5.7 (testcontainers#2966)
  feat!: log package for consistent output (testcontainers#2979)
  docs: remove duplicated options in the customisers lists (testcontainers#2989)
  chore: exclude "modules/k6" from the build (testcontainers#2987)
  chore: enable var-naming from revive (private vars only) (testcontainers#2978)
  chore(deps): bump actions/checkout from 4.1.7 to 4.2.2 (testcontainers#2971)
  chore(deps): bump release-drafter/release-drafter from 6.0.0 to 6.1.0 (testcontainers#2970)
  chore!: remove variadic arguments from nats ConnectionString (testcontainers#2967)
  fix(ci): use same condition for sonar steps (testcontainers#2974)
  fix: return unique modified modules (testcontainers#2973)
  chore(deps): bump golangci/golangci-lint-action from 6.2.0 to 6.3.0 (testcontainers#2969)
  chore(ci): run lint in a separate build before running the tests (testcontainers#2876)
  fix(deps): update to github.com/shirou/gopsutil/v4 (testcontainers#2964)
  fix(valkey): fix port race (testcontainers#2962)
  chore(deps): bump golang.org/x/net in /modules/pinecone (testcontainers#2963)
  chore(deps): bump golang.org/x/net from 0.26.0 to 0.33.0 (testcontainers#2961)
  deps(fix): include modulegen templates dir in dependabot updates (testcontainers#2956)
  chore(deps): bump docker/setup-docker-action from 4.0.0 to 4.1.0 (testcontainers#2959)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change Causing compatibility issues. feature New functionality or new behaviors on the existing one

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants