swift-log icon indicating copy to clipboard operation
swift-log copied to clipboard

Provide Test Helpers Publicly

Open Mordil opened this issue 2 years ago • 7 comments

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

Mordil avatar Dec 22 '22 03:12 Mordil

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

  • https://github.com/apple/swift-distributed-actors/blob/main/Sources/DistributedActorsTestKit/LogCapture.swift
  • (and same in cluster membership: https://github.com/apple/swift-cluster-membership/blob/main/Tests/SWIMTestKit/LogCapture.swift )

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

ktoso avatar Dec 22 '22 04:12 ktoso

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.

glbrntt avatar Dec 22 '22 09:12 glbrntt

+1

tomerd avatar Dec 22 '22 17:12 tomerd

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

Mordil avatar Jun 22 '23 19:06 Mordil

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.

ktoso avatar Jun 23 '23 01:06 ktoso

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

Mordil avatar Jun 28 '23 17:06 Mordil

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!

brimworks avatar Aug 19 '24 23:08 brimworks