Skip to content

[Enhancement]: Reduce verbose log output #1984

@mfridman

Description

@mfridman

Proposal

The default log output from this package is quite verbose. It would be ideal if the happy path (by default) logged as little as possible and reported only errors. And for those that do want verbose output, there could be a "verbose" flag or setting that could be enabled.

TL;DR - regardless if it's opt-in or opt-out, it'd be nice for this to be configurable.


  1. I explicitly disabled this feature, no need for this output:
**********************************************************************************************
Ryuk has been disabled for the current execution. This can cause unexpected behavior in your environment.
More on this: https://golang.testcontainers.org/features/garbage_collector/
**********************************************************************************************
  1. Not really interested in the Docker engine info:
2023/12/06 21:56:59 github.com/testcontainers/testcontainers-go - Connected to docker: 
  Server Version: 24.0.6
  API Version: 1.43
  Operating System: Docker Desktop
  Total Memory: 7944 MB
  Resolved Docker Host: unix:///var/run/docker.sock
  Resolved Docker Socket Path: /var/run/docker.sock
  Test SessionID: be5bcf090d5ac5b55046d7a35a670ab7341c71919218f6ee1e64ea4190322e69
  Test ProcessID: 469ede8f-9797-46fb-9ce8-eccb642a0d47
  1. This is cute (hehe), but not strictly necessary:
2023/12/06 21:50:06 🐳 Creating container for image postgres:16-alpine
2023/12/06 21:50:06 ✅ Container created: f40dcefbd017
2023/12/06 21:50:06 🐳 Starting container: f40dcefbd017
2023/12/06 21:50:07 ✅ Container started: f40dcefbd017
2023/12/06 21:50:07 🚧 Waiting for container id f40dcefbd017 image: postgres:16-alpine. Waiting for: &{timeout:<nil> deadline:0xc0001a6e98 Strategies:[0xc0003b1a40]}

[...]

2023/12/06 22:15:03 🐳 Terminating container: f40dcefbd017
2023/12/06 22:15:03 🚫 Container terminated: f40dcefbd017

I added a custom logger, but it only suppressed items 2 and 3 above.

type nopLogger struct{}

var _ testcontainers.Logging = nopLogger{}

func (nopLogger) Printf(string, ...interface{}) {}

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions