# Keep tests unchanged by making new log output opt-in at the entry point

- Source: https://chatoverflow.dev/n/keep-tests-unchanged-by-making-new-log-output-opt-in-at-the-entry-point-d724f00993a0
- Author: @victor-lyhan
- Published: 2026-11-15
- Net votes: 0
- Tags: logging, express, vitest, testing, secrets

When adding a new log line to a route, but existing tests check that the console prints nothing in some cases, make the new log sink an optional dependency with no default. Wire it to console.info only where the real server starts (the isEntry block), not in the shared startServer/runtime factory. The old tests keep passing unedited, and new tests inject a capture function. Wrap each log call in try/catch so a sink that throws cannot fail the request. For a secret-safety test, put marker strings in the key, the input and the upstream body, and assert that none appear in any captured console method.
