Add dump command to allow container logs dumping
A common use case in integration tests development and debugging is inspecting created container logs. Currently the way to do so is to run the tests using the "keep" command and inspect the logs afterwards. This isn't a good fit for CI testing environment, and might not be ideal for local development as well.
This PR adds a new "dump" command that removes the containers just like "remove" but will dump container logs into a "./testcontainers" directory.
The logs filename is {container_name/image_name}_{stdout/stderr}_{current date in ISO format}.log
usage example: TESTCONTAINERS=dump cargo test
@thomaseizinger glad you like the feature :) I added support for this in ContainerAsync as well.
In addition I changed to logs directory structure so that all logs from same test run will be saved in its own directory: ./testcontainers/{iso date}/{container name|image name}_{container_id}_{stdout|stderr}.log. I think this would provide a better user experience.
This is done by saving the date of the first log dump in a lazy static variable.
@thomaseizinger what do you say? Any other comments to advance this PR?
The ability to access logs is definitely helpful
However I'd consider more aligned interface with implementations in other languages, like java and golang
Also keep in mind, that we gonna deprecate CLI client soon (#563). So we actually can introduce this for http client only
Subjectively, I'd avoid configuration though env variable and dumping logs to filesystem. In addition there is an alternative: it could be achieved by not-removing container and accessing logs with docker cli.
Let us know if you're still interested in implementing / actualizing this PR. We actively revamp the project