apple / swift-log

A Logging API for Swift
https://apple.github.io/swift-log/
Apache License 2.0
3.48k stars 285 forks source link

Provide Test Helpers Publicly #242

Open Mordil opened 1 year ago

Mordil commented 1 year ago

I have my own test helpers for validating logging behavior in my library

after writing tests for #243... the test helpers are much nicer than what I wrote.

It'd be nice if the helpers were made public in a LoggingTestUtils module to be imported in my test targets...

ktoso commented 1 year ago

Rather, we wanted to provide the LogCapture libs, like the one that distributed actors has implemented:

I forgot what that got stuck on, was it you @glbrntt or @fabianfett who was looking into this or am I misremembering?

We provided such for metrics, so we should do the same for log perhaps. For metrics it is: https://github.com/apple/swift-metrics-extras/tree/main/Sources/MetricsTestUtils which also was extracted from distributed actors cluster

glbrntt commented 1 year ago

gRPC does similar. I don't recall looking into making this a feature of swift-log though.

It would be great if we did have this though as it's a useful utility and annoying for folks to have to re-invent it each time they want it.

tomerd commented 1 year ago

+1

Mordil commented 1 year ago

Where are we at with this? Is this something that just needs a PR?

ktoso commented 1 year ago

Just someone needs to do it, yes. If you're interested help here would be welcome.

It'd live in a LoggingTestKit the same as we do for metrics test kit. You can base the implementation on what the distributed cluster does.

Mordil commented 1 year ago

Awesome. I'll look into creating a submission next week while I take extra time off for the US holiday weekend

brimworks commented 3 weeks ago

This seems to have languished, so I put together this proposal: https://github.com/apple/swift-log/pull/316

If I get the thumbs up, then I'll put together a PR with that implementation. Please provide feedback in the above PR about the approach.

Thanks!