Logs showing up in release mode


#1

I was surprised to see my logs showing up in release mode both in Windows and Mac.

In windows it uses

OutputDebugString ((text + "\n").toWideCharPointer());

And in Mac:

std::cerr << text << std::endl;

I run a short search in Stackoverflow and found one way to tackle this (Windows):

#ifdef _DEBUG
    #define LOGMESSAGE( str ) OutputDebugString( str );
#else
    #define LOGMESSAGE( str )
#endif

#2

Eh?

It depends what you’re using to write to the log… If you use the DBG macro, then it’s disabled in release mode.


#3

oh, thanks Jules.

I’ll replace the calls to DBG.


#4

Wouldn’t it also be better to change WriteToLog() to use DBG?

void Logger::writeToLog (const String& message)
{
    if (currentLogger != nullptr)
        currentLogger->logMessage (message);
    else
        outputDebugString (message);
}

#5

No. If it was supposed to work like that, I’d have called it “writeToLogExceptInReleaseMode”.


#6

Most of my bugs are in my Release build. They disappear in the Debug verison :frowning:


#7

Most of my bugs are in my Release build. They disappear in the Debug verison :-([/quote]

That sounds familiar. Many of mine only activate when they leave my office.