From e2a70873b826085ac8db2fc751a2d41389b49392 Mon Sep 17 00:00:00 2001 From: orignal Date: Sat, 5 Mar 2016 21:46:01 -0500 Subject: [PATCH] fixed garbage in console for windows --- DaemonWin32.cpp | 9 ++++++++- Log.h | 6 ++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/DaemonWin32.cpp b/DaemonWin32.cpp index 4ab65040..bf5f938c 100644 --- a/DaemonWin32.cpp +++ b/DaemonWin32.cpp @@ -68,7 +68,14 @@ namespace i2p SetConsoleOutputCP(1251); setlocale(LC_ALL, "Russian"); - return Daemon_Singleton::start(); + bool ret = Daemon_Singleton::start(); + if (ret && IsLogToFile ()) + { + // TODO: find out where this garbage to console comes from + SetStdHandle(STD_OUTPUT_HANDLE, INVALID_HANDLE_VALUE); + SetStdHandle(STD_ERROR_HANDLE, INVALID_HANDLE_VALUE); + } + return ret; } bool DaemonWin32::stop() diff --git a/Log.h b/Log.h index 5b07e2c9..363a23b5 100644 --- a/Log.h +++ b/Log.h @@ -45,6 +45,7 @@ class Log: public i2p::util::MsgQueue std::shared_ptr GetLogStream () const { return m_LogStream; }; const std::string& GetTimestamp (); LogLevel GetLogLevel () { return m_MinLevel; }; + const std::string& GetFullFilePath () const { return m_FullFilePath; }; private: @@ -110,6 +111,11 @@ inline void ReopenLogFile () g_Log->ReopenLogFile (); } +inline bool IsLogToFile () +{ + return g_Log ? !g_Log->GetFullFilePath ().empty () : false; +} + template void LogPrint (std::stringstream& s, TValue arg) {