CleanroomLogger icon indicating copy to clipboard operation
CleanroomLogger copied to clipboard

Behavior of minimumSeverity in XcodeLogConfiguration initializer is confusing w/r/t debugMode & verboseDebugMode

Open AndresCanella opened this issue 7 years ago • 6 comments

I've been trying what according to documentation should work but can not get 'debug' level printout.

Log.enable(configuration: [XcodeLogConfiguration(minimumSeverity: .debug)])
Log.info?.message("info")
Log.debug?.message("debug")
Log.error?.message("error")

output:

2017-06-01 17:03:11.703661-0600 xxx[81389:1957145] [CleanroomLogger] 🔷 info (AppDelegate.swift:20)
2017-06-01 17:03:11.704036-0600 xxx[81389:1957145] [CleanroomLogger] ❌ error (AppDelegate.swift:22)

^ debug level missing.

While changing minimumSeverity to 'error' will cause the 'info' log to be omitted, so it seems to be an internal issue:

Log.enable(configuration: [XcodeLogConfiguration(minimumSeverity: .error)])
Log.info?.message("info")
Log.debug?.message("debug")
Log.error?.message("error")

output:

2017-06-01 17:08:44.419152-0600 xxx[81598:1961660] [CleanroomLogger] ❌ error (AppDelegate.swift:22)

Is this a bug, or what am I missing?

AndresCanella avatar Jun 01 '17 23:06 AndresCanella

Hi Andres,

To make it simple for external flags to control debugging-related behavior, the XcodeLogConfiguration initializer takes two parameters that affect this:

There's a debugMode argument and another called verboseDebugMode. Both of these accept a Bool value that will enable logging at the .debug and .verbose levels respectively. When not explicitly specified, these values default to false.

We use this, for example, to set separate DEBUG and VERBOSE flags (using the SWIFT_ACTIVE_COMPILATION_CONDITIONS build setting in Xcode).

This is described a bit more in the documentation, but now that I see the confusion, I'm thinking I might need to change it so minimumSeverity always overrides those values when they're false.

Hope this helps, E.

emaloney avatar Jun 02 '17 18:06 emaloney

Thanks! Turns out the issue is happening only on the simulator, does not happen on the device.

AndresCanella avatar Jun 07 '17 19:06 AndresCanella

The behavior you're seeing doesn't sound intentional, and I'm wondering if something else is going on. When you're viewing the output of the logs, are you viewing then through the Mac's Console.app, through the Xcode console pane, or reading log files?

Also, if nothing obvious becomes apparent, would you mind sending me source I could use to try to replicate the problem for myself?

emaloney avatar Jun 08 '17 06:06 emaloney

Further testing... The issue only seems t happen in appCode, using the simulator.

appCode, Sim - Issue, only 'Info' as originally noted. appCode, Device - Works as expected. Xcode, sim -Works as expected. Xcode Device - Works as expected.

Let me know if you have trouble replicating the issue.

AndresCanella avatar Jun 16 '17 01:06 AndresCanella

@AndresCanella I'm having a similar issue, but it doesn't seem to work for me on the device. I'm using a real device and XCode. Here's my code:

        Log.enable(minimumSeverity: .verbose,
                   debugMode: true,
                   verboseDebugMode: true,
                   stdStreamsMode: .useAsFallback,
                   mimicOSLogOutput: true,
                   showCallSite: true,
                   filters: [])

        Log.verbose?.message("* Verbose")
        Log.debug?.message("* Debug")
        Log.info?.message("* Info")
        Log.warning?.message("* Warning")
        Log.error?.message("* Error")

And my output:

2017-06-22 10:20:18.882173-0700 RhombusAppStore[6855:2805459] [CleanroomLogger] 🔷 * Info (AppDelegate.swift:175)
2017-06-22 10:20:18.882409-0700 RhombusAppStore[6855:2805459] [CleanroomLogger] 🔶 * Warning (AppDelegate.swift:176)
2017-06-22 10:20:18.882531-0700 RhombusAppStore[6855:2805459] [CleanroomLogger] ❌ * Error (AppDelegate.swift:177)

andrewagain avatar Jun 22 '17 17:06 andrewagain

Note when using the Console.App to view your logs:
be sure to enable "Action --> Enable Debug Messages/Info Messages" from the Menu. Those options are off by default...

gave me a small headache before discovering this

schmidan avatar Jul 25 '17 13:07 schmidan