Skip to content

How to fix DDLogXYZ deprecation? #1394

Closed Answered by ffried
AntonDe asked this question in Q&A
Discussion options

You must be logged in to vote

Simply use a Swift string literal for logging messages:

DDLogInfo("My log message")

If you have parameters in your log message, use a Swift string interpolation:

let parameter = "My Parameter"
DDLogInfo("My log message with parameter: \(parameter)")
Old vs. new examples

If you've previously had a string as the message in a separate variable, inline it into the DDLogXYZ call. Alternatively, declare it as a DDLogMessageFormat. Note however, that the latter will always evaluate the message even if won't be logged due to the configured level.

Old:

let message = "My message"
DDLogInfo(message)

New:

DDLogInfo("My message")
// OR (always evaluating the message)
let message: DDLogMessageFormat = "

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ffried
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
2 participants
Converted from issue

This discussion was converted from issue #1393 on November 20, 2023 09:58.