Is there a way to make interpolated strings public by default with apples Logger?

Viewed 42

In swift, I use code like this:

let logger = Logger()
let someInfo = "information"
logger.warning("blah: \(someInfo)")

but the console output shows: blah: \<private>

unless I change the final line to:

logger.warning("blah: \(someInfo, privacy: .public)")

I'm wondering if there is a way to make the default to be .public -- while I am developing my app, I want to see all of the messages -- without having to include the privacy: .public everywhere.

edit: I am using a workaround for now, but I don't love the solution, and hoping there is some official support, the workaround I'm using is a method like this:

static func logwarn(_ message: String) {
  let logger = Logger()
  logger.warning("\(message, privacy: .public)")
}

then I call logwarn, and can ifdef it so that it's implemented differently / not public in release code.

Thanks :)

0 Answers
Related