Skip to content

Make the logger replaceable #1568

Open
Open

Description

@cristianrgreco

What happens

All logging goes through the debug package, under six namespaces (testcontainers, testcontainers:containers, :compose, :build, :pull, :exec). The only control is the DEBUG environment variable.

  • Logs cannot be sent to the application's logger or to a test reporter.
  • The level cannot be set from code.
  • Nothing is shown by default, so the first pull of a large image looks like a hang.
  • When NODE_ENV is test, the logger switches its output from stderr to console.log.

Expected

  • A logger interface that can be replaced: setLogger({ debug, info, warn, error }).
  • The debug-based logger stays the default, so DEBUG=testcontainers* keeps working.
  • Container, build, pull and exec output remain separable.

Where

packages/testcontainers/src/common/logger.ts and its exported instances.

Notes

  • Go has log.SetDefault(logger). Java logs through SLF4J, so the application chooses the backend.
  • log is exported from the package today, so its shape is public API.

Dependencies

  • Nothing blocks this. It can start now.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestminorBackward compatible functionality

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions