-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[stdlib/private][OSLog] Support expressive, fprintf-style formatting options for integers passed to os log string interpolation. #29518
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
[stdlib/private][OSLog] Support expressive, fprintf-style formatting options for integers passed to os log string interpolation. #29518
Conversation
abd7e58
to
3c5d62e
Compare
@swift-ci Please test |
Build failed |
@swift-ci Please smoke test Linux Platform |
@swift-ci Please test Linux Platform |
3c5d62e
to
4b70b90
Compare
Rebasing on latest master and resolving conflicts. |
@swift-ci Please test |
Build failed |
@swift-ci Please test macOS Platform |
Build failed |
@swift-ci Please smoke test |
@swift-ci Please test macOS Platform |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd recommend carefully naming a few things, otherwise LGTM
@@ -0,0 +1,317 @@ | |||
@frozen | |||
public struct IntegerFormatting: Equatable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd pick a specific name to avoid potential future conflicts or shadowing like OSLogIntegerFormatting
@@ -0,0 +1,67 @@ | |||
@frozen | |||
public enum CollectionBound { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd pick a specific name to avoid potential future conflicts or shadowing like OSCollectionBound
|
||
extension String { | ||
@frozen | ||
public struct Alignment { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd pick a specific name to avoid potential future conflicts or shadowing like OSLogStringAlignment, and not have this be in the String namespace
options for integers passed to os log string interpolation.
4b70b90
to
4f2a55b
Compare
Pushed a commit that fixes the comments. |
@swift-ci Please test and merge |
1 similar comment
@swift-ci Please test and merge |
@milseman This PR adds the
IntegerFormatting.swift
andStringAlignment.swift
features to the new os log overlay, and updates the OSLog test suites to make it compatible with these changes. These files are almost same as what you had made, expect for the following changes:I have omitted the
separator
option ofIntegerFormatting
. This is because, as of now, os log is not supporting custom separators and therefore I did not want the option to be available to os log users. Similarly, I have also omittedFill
character fromString.Alignment
as os log would not be supporting anything but spaces, as of now.I have updated the implementation of
formatSpecifier
function slightly so that it uses only operations supported by the constant evaluator. This mostly involves replacing all string operations with +=.The
formatSpecifier
function now takes the privacy specifiers also as a parameter as they also add a flag to the format specifier.I have made the
formatSpecifier
function return a String instead of an optional String?. The conditions under which the function returned nil are now turned into precondition failures. This would enable the constant evaluator to report a reason for failure at compile time when those conditions are reached (without having to return an explicit error message).I have not yet added support for formatting strings. I will create a new PR for that.