summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrandon Diamond <brandon@10gen.com>2011-10-28 16:28:25 -0400
committerBrandon Diamond <brandon@10gen.com>2012-02-15 16:46:57 -0500
commitf96f1c70ec5154a07c1171b421953961ea480737 (patch)
tree9fc5b9773b5008dac601180ddbe0beaf4da208d8
parent24e1f0b92e438f336a3d7acac4f341eaddd89af2 (diff)
downloadmongo-f96f1c70ec5154a07c1171b421953961ea480737.tar.gz
CS-1535: Avoid writing to stderr unless dumping to stdout
-rw-r--r--tools/dump.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/tools/dump.cpp b/tools/dump.cpp
index a1690b2815f..971575d4b63 100644
--- a/tools/dump.cpp
+++ b/tools/dump.cpp
@@ -37,7 +37,7 @@ class Dump : public Tool {
FILE* _f;
};
public:
- Dump() : Tool( "dump" , ALL , "*" , "*" , false ) {
+ Dump() : Tool( "dump" , ALL , "*" , "*" , true ) {
add_options()
("out,o", po::value<string>()->default_value("dump"), "output directory or \"-\" for stdout")
("query,q", po::value<string>() , "json query" )
@@ -47,6 +47,19 @@ public:
;
}
+ virtual void preSetup() {
+ string out = getParam("out");
+ if ( out == "-" ) {
+ // write output to standard error to avoid mangling output
+ // must happen early to avoid sending junk to stdout
+ useStandardOutput(false);
+ }
+ }
+
+ virtual void printExtraHelp(ostream& out) {
+ out << "Export MongoDB data to BSON files.\n" << endl;
+ }
+
// This is a functor that writes a BSONObj to a file
struct Writer {
Writer(FILE* out, ProgressMeter* m) :_out(out), _m(m) {}