Skip to content

Commit b57cdea

Browse files
committed
Better fix for Windows logging
1 parent dda17c5 commit b57cdea

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

src/ngscopeclient/main.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,26 +65,25 @@ int main(int argc, char* argv[])
6565

6666
}
6767

68+
//Set up logging to the GUI
69+
g_guiLog = new GuiLogSink(console_verbosity);
70+
g_log_sinks.push_back(unique_ptr<GuiLogSink>(g_guiLog));
71+
6872
//If on Windows, and not run from a console
6973
//remove the stdout log sink that would otherwise spawn a console on startup
7074
#ifdef _WIN32
7175
if(getenv("PROMPT") != nullptr)
72-
{
73-
if(g_log_sinks.size() > 0)
74-
{
75-
g_log_sinks.erase(g_log_sinks.begin());
76-
LogDebug("Startup: removing stdout log sink since not run from a console\n");
77-
}
76+
LogDebug("Startup: skipping stdout log sink since not run from a console\n");
7877
}
7978
else
79+
{
80+
#endif
81+
g_log_sinks.push_back(make_unique<ColoredSTDLogSink>(console_verbosity));
82+
#ifdef _WIN32
8083
LogDebug("Startup: run from a console, keeping stdout log sink attached\n");
84+
}
8185
#endif
8286

83-
//Set up logging
84-
g_guiLog = new GuiLogSink(console_verbosity);
85-
g_log_sinks.push_back(make_unique<ColoredSTDLogSink>(console_verbosity));
86-
g_log_sinks.push_back(unique_ptr<GuiLogSink>(g_guiLog));
87-
8887
//Complain if the OpenMP wait policy isn't set right
8988
const char* policy = getenv("OMP_WAIT_POLICY");
9089
#ifndef _WIN32

0 commit comments

Comments
 (0)