FR: Ability to disable/override juce::Logger::outputDebugString

On mac, juce::Logger::outputDebugString writes to stderr meaning any calls to DBG also write to stderr. To some parsers, this looks as though there’s an error in the program.

It would be really useful to have a way to disable, override, or re-route the output of outputDebugString to not go to stderr.

Alternatively, a way to disable DBG without needing to build in release.


My particular use-case is with the C++ TestMate extension for VSCode which can find tests in an executable using Catch2, GoogleTest, etc. However, if the extension finds that the executable writes to stderr, it fails to parse:

Screenshot 2021-11-29 at 11.31.21

Which means, without manually removing all calls to DBG in my test-runner, I can’t use this extension.

Perhaps, instead of calling DBG directly, you could use a custom macro that compiles to Logger::writeToLog in debug, and nothing in release. This way, you have the option of overriding the logging behaviour by calling Logger::setCurrentLogger. If you don’t configure the logger in any way, it will call through to outputDebugString.

Would this approach work for your use-case?

Yeah I think something like that would probably work for the meantime… However there are quite a few places within JUCE that use the DBG macro - some of them have ways to disable logging (like the JUCE version printing) but others seem to be fixed.

So I also tried simply setting JUCE_DISABLE_ASSERTIONS to 1, which also works - however now the jassertfalse, jassert() macros obviously aren’t enabled which isn’t ideal.


Also, in trying this - there’s an unused variable error here when assertions are disabled:

changing to jassertquiet seemed to fix it for me!

Thanks, I’ve added that on develop:

1 Like