diff options
author | Henrik Edin <henrik.edin@mongodb.com> | 2018-07-16 10:39:06 -0400 |
---|---|---|
committer | Henrik Edin <henrik.edin@mongodb.com> | 2018-07-23 11:38:25 -0400 |
commit | a73722cc85bd1027898be8af651e1312d68a680b (patch) | |
tree | 212b99745426b2168e86bf3b96cf11439e964077 /src/mongo/logger | |
parent | fc372cdf9a070eecaf600b75649fd2690c3d927d (diff) | |
download | mongo-a73722cc85bd1027898be8af651e1312d68a680b.tar.gz |
SERVER-36209 Log to Visual Studio Debug Output in debug builds if debugger is attached.
Diffstat (limited to 'src/mongo/logger')
-rw-r--r-- | src/mongo/logger/console.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/mongo/logger/console.cpp b/src/mongo/logger/console.cpp index b16e1b6270d..da2f0c236af 100644 --- a/src/mongo/logger/console.cpp +++ b/src/mongo/logger/console.cpp @@ -32,6 +32,7 @@ #include <iostream> #include "mongo/base/init.h" +#include "mongo/config.h" #ifdef _WIN32 #include <io.h> @@ -67,7 +68,7 @@ public: setp(&(_buffer[0]), &(_buffer[_bufferSize - 1])); } - int_type overflow(int_type ch) { + int_type overflow(int_type ch) override { if (ch == traits_type::eof()) { return ch; } @@ -138,7 +139,7 @@ public: return flushToConsole() ? ch : traits_type::eof(); } - int sync() { + int sync() override { return flushToConsole() ? 0 : -1; } @@ -178,6 +179,14 @@ private: unwrittenCount -= written; unwrittenBegin += written; } + +#ifdef MONGO_CONFIG_DEBUG_BUILD + if (IsDebuggerPresent()) { + bufferWide[std::min(static_cast<size_t>(length), _bufferSize - 1)] = L'\0'; + OutputDebugStringW(bufferWide); + } +#endif + return true; } |