apple / swift-openapi-urlsession

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

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

Closed simonjbeaumont closed 10 months ago

simonjbeaumont commented 10 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