0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

minor nicer logging

This commit is contained in:
dwight 2009-01-04 20:09:31 -05:00
parent b726cbeed5
commit ffc3bb2216
5 changed files with 23 additions and 14 deletions

View File

@ -27,7 +27,7 @@
#include "dbmessage.h"
#include "instance.h"
extern bool objcheck, quiet, quota, verbose;
extern bool objcheck, quiet, quota, verbose, cpu;
bool useJNI = true;
/* only off if --nocursors which is for debugging. */
@ -113,9 +113,8 @@ void pdfileInit();
115 replay, opLogging
*/
void listen(int port) {
const char *Version = "db version: 122";
problem() << Version << endl;
problem() << "pdfile version " << VERSION << "." << VERSION_MINOR << endl;
const char *Version = "db version 122";
log() << Version << ", pdfile version " << VERSION << "." << VERSION_MINOR << endl;
pdfileInit();
//testTheDb();
log() << "waiting for connections on port " << port << "..." << endl;
@ -460,6 +459,8 @@ int main(int argc, char* argv[], char *envp[] )
goto usage;
else if ( s == "--quiet" )
quiet = true;
else if( s == "--cpu" )
cpu = true;
else if ( s == "--verbose" )
verbose = true;
else if ( s == "--quota" )
@ -512,7 +513,8 @@ usage:
cout << " --help show this usage information\n";
cout << " --port <portno> specify port number, default is 27017\n";
cout << " --dbpath <root> directory for datafiles, default is /data/db/\n";
cout << " --quiet quieter output (no cpu outputs)\n";
cout << " --quiet quieter output\n";
cout << " --cpu show cpu+iowait utilization periodically\n";
cout << " --verbose\n";
cout << " --objcheck inspect client data for validity on receipt\n";
cout << " --quota enable db quota management\n";

View File

@ -31,6 +31,7 @@
#include "db.h"
#include "instance.h"
extern bool quiet;
extern int queryTraceLevel;
extern int otherTraceLevel;
extern int opLogging;
@ -316,7 +317,8 @@ public:
bool run(const char *ns, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool) {
opLogging = (int) cmdObj.findElement(name).number();
flushOpLog();
log() << "CMD: opLogging set to " << opLogging << endl;
if( !quiet )
log() << "CMD: opLogging set to " << opLogging << endl;
return true;
}
} cmdoplogging;
@ -337,7 +339,8 @@ public:
virtual bool run(const char *ns, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool) {
string nsToDrop = database->name + '.' + cmdObj.findElement(name).valuestr();
NamespaceDetails *d = nsdetails(nsToDrop.c_str());
log() << "CMD: drop " << nsToDrop << endl;
if( !quiet )
log() << "CMD: drop " << nsToDrop << endl;
if ( d == 0 ) {
errmsg = "ns not found";
return false;
@ -451,7 +454,8 @@ public:
BSONElement e = jsobj.findElement(name.c_str());
string toDeleteNs = database->name + '.' + e.valuestr();
NamespaceDetails *d = nsdetails(toDeleteNs.c_str());
log() << "CMD: deleteIndexes " << toDeleteNs << endl;
if( !quiet )
log() << "CMD: deleteIndexes " << toDeleteNs << endl;
if ( d ) {
BSONElement f = jsobj.findElement("index");
if ( !f.eoo() ) {
@ -595,7 +599,8 @@ bool _runCommands(const char *ns, BSONObj& _cmdobj, stringstream& ss, BufBuilder
valid = true;
string dropNs = us + '.' + e.valuestr();
NamespaceDetails *d = nsdetails(dropNs.c_str());
log() << "CMD: clean " << dropNs << endl;
if( !quiet )
log() << "CMD: clean " << dropNs << endl;
if ( d ) {
ok = true;
anObjBuilder.append("ns", dropNs.c_str());
@ -609,7 +614,8 @@ bool _runCommands(const char *ns, BSONObj& _cmdobj, stringstream& ss, BufBuilder
valid = true;
string toValidateNs = us + '.' + e.valuestr();
NamespaceDetails *d = nsdetails(toValidateNs.c_str());
log() << "CMD: validate " << toValidateNs << endl;
if( !quiet )
log() << "CMD: validate " << toValidateNs << endl;
if ( d ) {
ok = true;
anObjBuilder.append("ns", toValidateNs.c_str());

View File

@ -53,7 +53,7 @@ Timing tlast;
const int NStats = 32;
string lockStats[NStats];
unsigned q = 0;
extern bool quiet;
extern bool cpu;
void statsThread() {
unsigned long long timeLastPass = 0;
@ -75,7 +75,7 @@ void statsThread() {
if ( dt )
ss << (dlocked*100)/dt << '%';
string s = ss.str();
if ( !quiet )
if ( cpu )
log() << "cpu: " << s << endl;
lockStats[q] = s;
}

View File

@ -58,6 +58,7 @@ void flushOpLog() {
int ctr = 0;
bool quiet = false;
bool cpu = false; // --cpu show cpu time periodically
bool verbose = false;
// Returns false when request includes 'end'

View File

@ -154,7 +154,7 @@ JavaJSImpl::JavaJSImpl(const char *appserverPath) {
_vmArgs->nOptions = 3;
_vmArgs->ignoreUnrecognized = JNI_FALSE;
log() << "Creating JVM" << endl;
log() << "loading JVM" << endl;
jint res = JNI_CreateJavaVM( &_jvm, (void**)&_mainEnv, _vmArgs );
if ( res ) {
@ -515,7 +515,7 @@ const char * findEd() {
continue;
closedir( test );
log() << "Found directory for appserver : " << temp << endl;
log() << "found directory for appserver : " << temp << endl;
return temp;
}