Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

CS-1535: Avoid writing to stderr unless dumping to stdout

  • Loading branch information...
commit f96f1c70ec5154a07c1171b421953961ea480737 1 parent 24e1f0b
Brandon Diamond authored
Showing with 14 additions and 1 deletion.
  1. +14 −1 tools/dump.cpp
15 tools/dump.cpp
View
@@ -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 @@ class Dump : public Tool {
;
}
+ 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) {}
Please sign in to comment.
Something went wrong with that request. Please try again.