Skip to content

Conversation

@fpseverino
Copy link
Contributor

Conform Logger.Level to CustomStringConvertible and LosslessStringConvertible.

Motivation:

There are libraries, such as Vapor, that add these conformances privately and @retroactively. This would avoid having to implement these conformances manually in each library and would unify and standardise the implementation.

Modifications:

Make Logger.Level conform to CustomStringConvertible and LosslessStringConvertible, adding a public description computed property that returns the rawValue and a public initializer that takes a description string, lowercases it, and passes it to the rawValue initializer.

Result:

Logger.Level conforms to CustomStringConvertible and LosslessStringConvertible.

…ngConvertible`.

Motivation:

There are libraries, such as Vapor, that add these conformances privately and `@retroactive`ly. This would avoid having to implement these conformances manually in each library and would unify and standardise the implementation.

Modifications:

Make `Logger.Level` conform to `CustomStringConvertible` and `LosslessStringConvertible`, adding a public `description` computed property that returns the `rawValue` and a public initializer that takes a `description` string, lowercases it, and passes it to the `rawValue` initializer.

Result:

`Logger.Level` conforms to `CustomStringConvertible` and `LosslessStringConvertible`.
Copy link
Contributor

@czechboy0 czechboy0 left a comment

Choose a reason for hiding this comment

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

Oh I've wanted this for so long, just never got to open a PR - thank you @fpseverino 🙂

@fpseverino
Copy link
Contributor Author

I'm afraid I can't add the required label to the PR to make the CI pass

@czechboy0 czechboy0 added the 🆕 semver/minor Adds new public API. label Dec 7, 2025
@czechboy0 czechboy0 merged commit cdaa5ac into apple:main Dec 8, 2025
60 of 61 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🆕 semver/minor Adds new public API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants