summaryrefslogtreecommitdiff
path: root/src/mongo/util/log.cpp
diff options
context:
space:
mode:
authorShaun Verch <shaun.verch@10gen.com>2013-10-30 15:06:50 -0400
committerShaun Verch <shaun.verch@10gen.com>2013-11-26 23:25:26 -0500
commit1a78c32529cd9378479170b7577b1eb2509c61ca (patch)
tree30935cb856590914347bc2d87dea053556c2d67b /src/mongo/util/log.cpp
parent08790c849539ff868c101050860e56154297145f (diff)
downloadmongo-1a78c32529cd9378479170b7577b1eb2509c61ca.tar.gz
SERVER-10886 Create function to override rawOut destination stream to avoid corrupting tool output
Diffstat (limited to 'src/mongo/util/log.cpp')
-rw-r--r--src/mongo/util/log.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/mongo/util/log.cpp b/src/mongo/util/log.cpp
index b778b8cc006..ae24f924ffb 100644
--- a/src/mongo/util/log.cpp
+++ b/src/mongo/util/log.cpp
@@ -110,16 +110,30 @@ namespace mongo {
return s.str();
}
+ namespace {
+ // NOTE: We can't directly set this variable to something like "stdout" because we need to
+ // make sure that it is initialized properly before static initialization.
+ FILE *rawOutDestination = NULL;
+ } // namespace
+
+ void setRawOutDestination(FILE *outDestination) {
+ rawOutDestination = outDestination;
+ }
+
/*
* NOTE(schwerin): Called from signal handlers; should not be taking locks or allocating
* memory.
*/
void rawOut(const StringData &s) {
+ FILE* dest = rawOutDestination;
+ if (!dest) {
+ dest = stdout;
+ }
for (size_t i = 0; i < s.size(); ++i) {
#ifdef _WIN32
- putc(s[i], stdout);
+ putc(s[i], dest);
#else
- putc_unlocked(s[i], stdout);
+ putc_unlocked(s[i], dest);
#endif
}
}