Skip to content
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

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

Open
AndresCanella opened this issue Jun 1, 2017 · 6 comments

Comments

@AndresCanella
Copy link

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?

@emaloney
Copy link
Owner

emaloney commented Jun 2, 2017

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 emaloney changed the title Does not change log level. Behavior of minimumSeverity in XcodeLogConfiguration initializer is confusing w/r/t debugMode & verboseDebugMode Jun 2, 2017
@AndresCanella
Copy link
Author

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

@emaloney
Copy link
Owner

emaloney commented Jun 8, 2017

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?

@AndresCanella
Copy link
Author

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.

@andrewagain
Copy link

andrewagain commented Jun 22, 2017

@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)

@schmidan
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants