#if defined (SG_WINDOWS)
// Check for stream redirection, has to be done before we call
// Attach / AllocConsole
- const bool isFile = (GetFileType(GetStdHandle(STD_OUTPUT_HANDLE)) == FILE_TYPE_DISK); // Redirect to file?
+ const bool isFile = (GetFileType(GetStdHandle(STD_ERROR_HANDLE)) == FILE_TYPE_DISK); // Redirect to file?
if (AttachConsole(ATTACH_PARENT_PROCESS) == 0) {
// attach failed, don't install the callback
addStderr = false;
}
+
+ if (!isFile) {
+ // No - OK! now set streams to attached console
+ freopen("conout$", "w", stdout);
+ freopen("conout$", "w", stderr);
+ }
#endif
if (addStderr) {
-#if defined (SG_WINDOWS)
- if (!isFile) {
- // No - OK! now set streams to attached console
- freopen("conout$", "w", stdout);
- freopen("conout$", "w", stderr);
- }
-#endif
m_callbacks.push_back(new StderrLogCallback(m_logClass, m_logPriority));
m_consoleCallbacks.push_back(m_callbacks.back());
}