bunch
bunch copied to clipboard
Setting debugLevel preference via URL/CLI
TL;DR I don't think the preference setting of the logging level via the URL handler is working as expected.
Testing the Issue
From the URL Handler documentation page's setPref
section, I believe the following URL calls (e.g. via open
from the terminal) should modify the level for the Bunch Log - which corresponds to the levels shown in the menu at Help->Set Log Level, the level being indicated by a check mark.
-
x-bunch://setPref?debugLevel=1
-
x-bunch://setPref?debugLevel=2
-
x-bunch://setPref?debugLevel=3
-
x-bunch://setPref?debugLevel=4
Running them individually, I would expect to see the check mark on the Set Log Level menu varying between the different levels. When I run them, I do not see any such change. So if my expectations are correct, either the setting is not changing, or the change is not being reflected in the UI.
Secondary Validation with AppleScript
If I use the following AppleScript, I can confirm the numeric level and if I change it in the app, I get an alert to restart the app (which I do), and then the checked menu item shows as changed, and the AppleScript returns the changed level.
tell application "Bunch"
get preference "debug"
end tell
If the URL call was working, I would expect it would also pop up the same message, which leaves me leaning towards the URL call not working for debugLevel
.
Validation of Documentation
Given the AppleScript preference ID was "debug", I did try substituting it for "debugLevel" in the URL, just in case it was a documentation mismatch, but no luck there either.
CLI
Looking at the code for the CLI, that looks to use the same URL scheme approach to setting the preferences, and so I believe is by association affected in the same way.
Bunch App Details
I have mainly been using the Bunch Beta (and the x-bunch-beta://
handler), but I believe I have been able to reproduce this behaviour on both apps:
- Bunch Beta: Version 1.4.17 (180)
- Bunch: Version 1.4.17 (180)
Bonus Question: Does Debug Level Zero Really Exist?
There is a related point of confusion in that both the AppleScript documentation for getting preferences, and the URL handler documentation for setting preferences both indicate a five point scale for the logging level : 0-4. However, the user interface only has four listed levels.
I did wonder if selecting a selected item might turn off logging (that would be my first guess at what level 0 would be), but it doesn't, though it does prompt me to restart the app and retains the same logging level.
I'm happy to be corrected if I've misunderstood anything in the documentation or my tests, to provide any additional details, further test results, etc.
Thanks in advance for any support on this.
Stephen.
Ugh, I'm seeing what you're seeing but it's really hard to debug because the url handler opens the installed app instead of the version running in xcode. I'll dig into it as I'm able.
In response to the bonus question, yes, debug level 0 turns logging off entirely. I see the code to handle that in the source, but I don't remember why it wasn't added as a menu option. Will remedy that.
-Brett