summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTad Marshall <tad@10gen.com>2012-08-17 10:42:21 -0400
committerEliot Horowitz <eliot@10gen.com>2012-08-21 17:40:21 -0400
commitcbdd95429bcf28fdf887b8f94e709d418d513c48 (patch)
tree7d14a26020e460ee3c75c4d48432ff0f61442b09
parent7ab12c2e100da04aa7fcfe6946e5eae082777209 (diff)
downloadmongo-cbdd95429bcf28fdf887b8f94e709d418d513c48.tar.gz
SERVER-6778 use log() instead of cout for Windows stack trace
-rw-r--r--src/mongo/util/stacktrace.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/mongo/util/stacktrace.cpp b/src/mongo/util/stacktrace.cpp
index 1daebe8b23f..68528a187d4 100644
--- a/src/mongo/util/stacktrace.cpp
+++ b/src/mongo/util/stacktrace.cpp
@@ -9,10 +9,13 @@
#include <vector>
#ifdef _WIN32
+#include <sstream>
#include <stdio.h>
#include <boost/smart_ptr/scoped_array.hpp>
#include "mongo/platform/windows_basic.h"
#include <DbgHelp.h>
+#include "mongo/util/assert_util.h"
+#include "mongo/util/log.h"
#endif
#ifdef MONGO_HAVE_EXECINFO_BACKTRACE
@@ -169,7 +172,7 @@ namespace mongo {
BOOL ret = SymInitialize( process, NULL, TRUE );
if ( ret == FALSE ) {
DWORD dosError = GetLastError();
- os << "Stack trace failed, SymInitialize failed with error " <<
+ log() << "Stack trace failed, SymInitialize failed with error " <<
std::dec << dosError << std::endl;
return;
}
@@ -244,20 +247,21 @@ namespace mongo {
++sourceWidth;
size_t frameCount = traceList.size();
for ( size_t i = 0; i < frameCount; ++i ) {
- os << traceList[i].moduleName << " ";
+ std::stringstream ss;
+ ss << traceList[i].moduleName << " ";
size_t width = traceList[i].moduleName.length();
while ( width < moduleWidth ) {
- os << " ";
+ ss << " ";
++width;
}
- os << traceList[i].sourceAndLine << " ";
+ ss << traceList[i].sourceAndLine << " ";
width = traceList[i].sourceAndLine.length();
while ( width < sourceWidth ) {
- os << " ";
+ ss << " ";
++width;
}
- os << traceList[i].symbolAndOffset;
- os << std::endl;
+ ss << traceList[i].symbolAndOffset;
+ log() << ss.str() << std::endl;
}
}
}