Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SwiftLogNoOpLogHandler.init(_: String) #194

Merged
merged 1 commit into from
May 5, 2021

Conversation

glbrntt
Copy link
Contributor

@glbrntt glbrntt commented May 5, 2021

Motivation:

LogHandler facotories are given a label as input and return a
LogHandler. Since the no-op handler doesn't care about the label
callers must provide a thunk: { _ in SwiftLogNoOpLogHandler() }.
That's fine but slightly more annoying to type than it needs to be.

Modifications:

  • Add SwiftLogNoOpLogHandler.init(_: String)

Result:

Users can create a logger with the no-op handler with:

Logger(label: "foo", factory: SwiftLogNoOpLogHandler.init)

instead of:

Logger(label: "foo", factory: { _ in SwiftLogNoOpLogHandler() })

Motivation:

`LogHandler` facotories are given a label as input and return a
`LogHandler`. Since the no-op handler doesn't care about the label
callers must provide a thunk: `{ _ in SwiftLogNoOpLogHandler() }`.
That's fine but slightly more annoying to type than it needs to be.

Modifications:

- Add `SwiftLogNoOpLogHandler.init(_: String)`

Result:

Users can create a logger with the no-op handler with:

```swift
Logger(label: "foo", factory: SwiftLogNoOpLogHandler.init)
```

instead of:

```swift
Logger(label: "foo", factory: { _ in SwiftLogNoOpLogHandler() })
```
@ktoso ktoso self-requested a review May 5, 2021 09:13
Copy link
Member

@ktoso ktoso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, makes sense to me -- happy to add 👍

Copy link
Member

@weissi weissi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense, thank you!

@ktoso ktoso added this to the 1.4.3 milestone May 5, 2021
@ktoso
Copy link
Member

ktoso commented May 5, 2021

Do people mind doing this on in 1.4.3 or should we 1.5.0? Technically it's new API

@weissi
Copy link
Member

weissi commented May 5, 2021

Do people mind doing this on in 1.4.3 or should we 1.5.0? Technically it's new API

Let's do 1.5.0, we don't need to release 1.4.3 at all.

@glbrntt
Copy link
Contributor Author

glbrntt commented May 5, 2021

+1 for 1.5.0, version numbers are cheap!

@ktoso
Copy link
Member

ktoso commented May 5, 2021

Cool, I can cut that tomorrow morning, unless you're in a rush (feel free to do the tags and milestones dance today if in a rush) :-)

@ktoso ktoso merged commit 08ec50d into apple:main May 5, 2021
@glbrntt glbrntt deleted the gb-no-op-handler branch May 5, 2021 10:03
@ktoso ktoso modified the milestones: 1.4.3, 1.5.0 May 5, 2021
@glbrntt
Copy link
Contributor Author

glbrntt commented May 5, 2021

No rush at all, this was just an itch I needed to scratch.

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.

3 participants