apple / swift-openapi-urlsession

URLSession transport for Swift OpenAPI Generator.
https://swiftpackageindex.com/apple/swift-openapi-urlsession/documentation
Apache License 2.0
159 stars 31 forks source link

Improve debug logging and add tests that it is not evaluated when disabled #26

Closed simonjbeaumont closed 11 months ago

simonjbeaumont commented 11 months ago

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 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

Result

Test Plan