diff options
author | bunnei <bunneidev@gmail.com> | 2018-11-05 00:19:59 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-05 00:19:59 -0500 |
commit | e10483a8782db9ac4b2d1727b721f20dec4330c3 (patch) | |
tree | e9757f8a9f85f7297a853f942d009b54307393cc /src/common/logging/backend.cpp | |
parent | acdc770cfbb3001818ded53daf44588b3d5deaa8 (diff) | |
parent | f5f6292810dab70bc9be0fa4d9f37fe2b5544d86 (diff) |
Merge pull request #1441 from CarlKenner/DebuggerLog
logging: Add DebuggerBackend for logging to Visual Studio
Diffstat (limited to 'src/common/logging/backend.cpp')
-rw-r--r-- | src/common/logging/backend.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index 6d52184650..5753b871a7 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp @@ -12,7 +12,8 @@ #include <thread> #include <vector> #ifdef _WIN32 -#include <share.h> // For _SH_DENYWR +#include <share.h> // For _SH_DENYWR +#include <windows.h> // For OutputDebugStringA #else #define _SH_DENYWR 0 #endif @@ -139,12 +140,18 @@ void FileBackend::Write(const Entry& entry) { if (!file.IsOpen() || bytes_written > MAX_BYTES_WRITTEN) { return; } - bytes_written += file.WriteString(FormatLogMessage(entry) + '\n'); + bytes_written += file.WriteString(FormatLogMessage(entry).append(1, '\n')); if (entry.log_level >= Level::Error) { file.Flush(); } } +void DebuggerBackend::Write(const Entry& entry) { +#ifdef _WIN32 + ::OutputDebugStringA(FormatLogMessage(entry).append(1, '\n').c_str()); +#endif +} + /// Macro listing all log classes. Code should define CLS and SUB as desired before invoking this. #define ALL_LOG_CLASSES() \ CLS(Log) \ |