The transport code has some debug logging, which is compile-time omitted in release builds, and only enabled in tests.
A number of tests produce an enormous amount of output (e.g. the streaming tests that pull 10GB through 10MB buffers), which are unwieldy in CI and locally.
Additionally, we found that the logging produced by these tests had interleaved output, both because of the mixed use of print and debug in tests and the lack of locking between multiple threads
Finally, even when running in debug mode with debug logging disabled, the function arguments to the debug function were still evaluated unnecessarily.
Modifications
Update the debug function to log to standard error (cf. standard out).
Pass an autoclosure as argument to debug so that it is only evaluated when logging is enabled.
Add a lock around the use of FileHandle.standardError.
Replace all stray uses of print in tests with debug.
Result
No debug logging should appear in tests by default (you can enable them locally when reproducing failures).
When enabled, log lines should not be all jumbled up.
When disabled, no string interpolation is performed.
Test Plan
Added tests that check that the log message is not interpolated when disabled.
Motivation
The transport code has some debug logging, which is compile-time omitted in release builds, and only enabled in tests.
A number of tests produce an enormous amount of output (e.g. the streaming tests that pull 10GB through 10MB buffers), which are unwieldy in CI and locally.
Additionally, we found that the logging produced by these tests had interleaved output, both because of the mixed use of
print
anddebug
in tests and the lack of locking between multiple threadsFinally, even when running in debug mode with debug logging disabled, the function arguments to the
debug
function were still evaluated unnecessarily.Modifications
debug
function to log to standard error (cf. standard out).debug
so that it is only evaluated when logging is enabled.FileHandle.standardError
.print
in tests withdebug
.Result
Test Plan