Swift 3.1 String(


(Maxim Veksler) #1

Hi,

Swift 3.1 compiler seems to introduces a new complier warning regarding
String(describing: )

So this line:

Log.info("Update name for user \(fbUser)")

Produces the warning: "note: use 'String(describing:)' to silence this
warning"

and becomes this line

Log.info("Update name for user \(String(describing: fbUser))")

This new syntax is not very sexy, especially for logging. Any suggestions,
possibility on the API end of Log to make this warning go away? or write it
differently.


(Shawn Erickson) #2

Avoid using optionals in string interpolation or make it explicit as the
fix-it suggests.

···

On Wed, Apr 5, 2017 at 7:27 AM Maxim Veksler via swift-users < swift-users@swift.org> wrote:

Hi,

Swift 3.1 compiler seems to introduces a new complier warning regarding
String(describing: )

So this line:

Log.info("Update name for user \(fbUser)")

Produces the warning: "note: use 'String(describing:)' to silence this
warning"

and becomes this line

Log.info("Update name for user \(String(describing: fbUser))")

This new syntax is not very sexy, especially for logging. Any suggestions,
possibility on the API end of Log to make this warning go away? or write it
differently.
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


(Rien) #3

Hi,

Swift 3.1 compiler seems to introduces a new complier warning regarding String(describing: )

So this line:
Log.info("Update name for user \(fbUser)”)

Log.info(“Update name for user \(fbUser ?? “Unknown”)”)

Rien.

···

On 05 Apr 2017, at 16:26, Maxim Veksler via swift-users <swift-users@swift.org> wrote:

Produces the warning: "note: use 'String(describing:)' to silence this warning"

and becomes this line
Log.info("Update name for user \(String(describing: fbUser))")

This new syntax is not very sexy, especially for logging. Any suggestions, possibility on the API end of Log to make this warning go away? or write it differently.
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


(Zhao Xin) #4

I always use `NSLog("Update name for user %@", fbUser)`. Is `Log.info` your
own implementation?

Zhaoxin

···

On Wed, Apr 5, 2017 at 10:26 PM, Maxim Veksler via swift-users < swift-users@swift.org> wrote:

Hi,

Swift 3.1 compiler seems to introduces a new complier warning regarding
String(describing: )

So this line:

Log.info("Update name for user \(fbUser)")

Produces the warning: "note: use 'String(describing:)' to silence this
warning"

and becomes this line

Log.info("Update name for user \(String(describing: fbUser))")

This new syntax is not very sexy, especially for logging. Any suggestions,
possibility on the API end of Log to make this warning go away? or write it
differently.

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


(David Sweeris) #5

I thought we couldn't nest quotes. Has that changed (because that would be fantastic)?

- Dave Sweeris

···

On Apr 5, 2017, at 07:49, Rien via swift-users <swift-users@swift.org> wrote:

On 05 Apr 2017, at 16:26, Maxim Veksler via swift-users <swift-users@swift.org> wrote:

Hi,

Swift 3.1 compiler seems to introduces a new complier warning regarding String(describing: )

So this line:
Log.info("Update name for user \(fbUser)”)

Log.info(“Update name for user \(fbUser ?? “Unknown”)”)


(Jon Shier) #6

This was something that sounded like a good change but is extremely annoying in use. Once I get time I’m going to try writing an extension on Optional that generates a logDescription property so I don’t have to use that awful String(describing:) API.

Jon Shier

···

On Apr 5, 2017, at 10:35 AM, Shawn Erickson via swift-users <swift-users@swift.org> wrote:

Avoid using optionals in string interpolation or make it explicit as the fix-it suggests.

On Wed, Apr 5, 2017 at 7:27 AM Maxim Veksler via swift-users <swift-users@swift.org <mailto:swift-users@swift.org>> wrote:
Hi,

Swift 3.1 compiler seems to introduces a new complier warning regarding String(describing: )

So this line:
Log.info("Update name for user \(fbUser)")

Produces the warning: "note: use 'String(describing:)' to silence this warning"

and becomes this line
Log.info("Update name for user \(String(describing: fbUser))")

This new syntax is not very sexy, especially for logging. Any suggestions, possibility on the API end of Log to make this warning go away? or write it differently.
_______________________________________________
swift-users mailing list
swift-users@swift.org <mailto:swift-users@swift.org>
https://lists.swift.org/mailman/listinfo/swift-users
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


(Vladimir) #7

Hi,

Swift 3.1 compiler seems to introduces a new complier warning regarding String(describing: )

So this line:
Log.info("Update name for user \(fbUser)”)

Log.info(“Update name for user \(fbUser ?? “Unknown”)”)

I thought we couldn't nest quotes. Has that changed (because that would be fantastic)?

Yes, this is working currently.
Btw, also should be mentioned that fbUser.debugDescription can be used explicitly to silence the warning, but 'Optional("username")' will be printed in log (instead of just 'username').

···

On 05.04.2017 20:30, David Sweeris via swift-users wrote:

On Apr 5, 2017, at 07:49, Rien via swift-users <swift-users@swift.org> wrote:

On 05 Apr 2017, at 16:26, Maxim Veksler via swift-users <swift-users@swift.org> wrote:

- Dave Sweeris
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


(Travis Griggs) #8

Couldn’t agree more. If you get your extension/fix done before me, share please?

···

On Apr 5, 2017, at 7:37 AM, Jon Shier via swift-users <swift-users@swift.org> wrote:

  This was something that sounded like a good change but is extremely annoying in use. Once I get time I’m going to try writing an extension on Optional that generates a logDescription property so I don’t have to use that awful String(describing:) API.