[2.1] OgreLog debuggerOutput printed twice on Windows

Minor issues with the Ogre API that can be trivial to fix
Post Reply
ArbitraryValue
Gnoblar
Posts: 14
Joined: Tue Mar 22, 2011 10:06 pm

[2.1] OgreLog debuggerOutput printed twice on Windows

Post by ArbitraryValue » Mon Jul 08, 2019 12:28 am

OgreLog.cpp contains the following code:

Code: Select all

                if (mDebugOut && !maskDebug)
                {
#    if (OGRE_PLATFORM == OGRE_PLATFORM_WIN32 || OGRE_PLATFORM == OGRE_PLATFORM_WINRT) && OGRE_DEBUG_MODE
#        if OGRE_WCHAR_T_STRINGS
                    OutputDebugStringW(message.c_str());
                    OutputDebugStringW(L"\n");
#        else
                    OutputDebugStringA(message.c_str());
                    OutputDebugStringA("\n");
#        endif
#    endif
                    if (lml == LML_CRITICAL)
                        std::cerr << message << std::endl;
                    else
                        std::cout << message << std::endl;
                }
I'm using the QTCreator IDE on Windows 10 and this causes every line of output to be printed twice, once from OutputDebugStringW/OutputDebugStringA and a second time from cerr/cout. I haven't tested with MSVC (presumably the more popular Windows use case) but for my setup I think using cerr/cout only if (OGRE_PLATFORM == OGRE_PLATFORM_WIN32 || OGRE_PLATFORM == OGRE_PLATFORM_WINRT) is false would be better.

Also I was going to add this to the bug tracker but the link in the "Rules for papercuts" post (https://www.ogre3d.org/mantis/) is dead.
0 x

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 4071
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 229
Contact:

Re: [2.1] OgreLog debuggerOutput printed twice on Windows

Post by dark_sylinc » Sat Jul 13, 2019 3:45 am

OutputDebugString and stdout are different.

stdout is useful if you're using your own console.

This is more of an issue that the particular IDE (QtCreator) is mixing both outputs in the same pane.
Probably the best solution is to add a boolean to mask the duplicated output at runtime adjusting to user's needs.
0 x

Post Reply