diff options
author | Eliot Horowitz <eliot@10gen.com> | 2010-11-03 18:28:12 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2010-11-03 18:57:19 -0400 |
commit | b741e68528ecfc6bb06f82355db1d9d8d0c4c43a (patch) | |
tree | 27316f24aae281417b0d2f69c20f9ea49b0da732 /tools/stat.cpp | |
parent | 2dce387d96b7edf2e920bf235fa5f6ec5422c063 (diff) | |
download | mongo-b741e68528ecfc6bb06f82355db1d9d8d0c4c43a.tar.gz |
better printing for mongos + shards SERVER-2038
Diffstat (limited to 'tools/stat.cpp')
-rw-r--r-- | tools/stat.cpp | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/tools/stat.cpp b/tools/stat.cpp index 780aef19798..fd5b9d18319 100644 --- a/tools/stat.cpp +++ b/tools/stat.cpp @@ -300,13 +300,20 @@ namespace mongo { cout << endl; } - static void printData( const BSONObj& o ){ - BSONObjIterator i(o); + static void printData( const BSONObj& o , const BSONObj& headers ){ + + BSONObjIterator i(headers); while ( i.more() ){ - BSONObj x = i.next().Obj(); - int w = x["width"].numberInt(); + BSONElement e = i.next(); + BSONObj h = e.Obj(); + int w = h["width"].numberInt(); - BSONElement data = x["data"]; + BSONElement data; + { + BSONElement temp = o[e.fieldName()]; + if ( temp.isABSONObj() ) + data = temp.Obj()["data"]; + } if ( data.type() == String ) cout << setw(w) << data.String(); @@ -314,6 +321,10 @@ namespace mongo { cout << setw(w) << setprecision(3) << data.number(); else if ( data.type() == NumberInt ) cout << setw(w) << data.numberInt(); + else if ( data.eoo() ) + cout << setw(w) << ""; + else + cout << setw(w) << "???"; cout << ' '; } @@ -351,7 +362,7 @@ namespace mongo { printHeaders( out ); } - printData( out ); + printData( out , out ); } catch ( AssertionException& e ){ @@ -557,7 +568,7 @@ namespace mongo { if ( rows[i].data.nFields() > biggest.nFields() ) biggest = rows[i].data; } - + // display data @@ -577,7 +588,7 @@ namespace mongo { else if ( rows[i].data.isEmpty() ) cout << "no data" << endl; else - printData( rows[i].data ); + printData( rows[i].data , biggest ); } } |