Skip to content

Conversation

@tgrapperon
Copy link
Owner

The current logger dependency fails when testing. We can't inspect messages that are logged and this dependency is so ubiquitous that it can be cumbersome to have to override it for every tests. It is thus probably preferable to make this dependency work without failing by default when testing. Users who want to assert that no logging occur can override the \.logger dependency with the .unimplemented value.

This commit also exposes some sugar to directly derive an OSSignposter value from a Logger. Its API suffers the same limitations of Logger regarding privacy, so, like Logger, we can't create a configurable/inspectable wrapper of this type. For this reason, the dependency directly produces an OSSignposter value.

You can use the provided subscript to emit signposts on any subsystem/category:

@Dependency(\.logger["Billing"].signpost) var signpost

signpost.emitEvent(
  "Purchase successful",
  "User \(userID, privacy: .private(mask: .hash)) did purchase item \(item, privacy: .auto)"
)

@tgrapperon tgrapperon changed the title Add OSSignposter sugar and make Logger not failing when testing. Add OSSignposter sugar and make Logger not fail when testing. Apr 19, 2023
@tgrapperon tgrapperon merged commit c73a674 into main Apr 23, 2023
@tgrapperon tgrapperon deleted the signpost branch April 23, 2023 05:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants