diff options
author | Dwight <dmerriman@gmail.com> | 2008-06-18 17:34:14 -0400 |
---|---|---|
committer | Dwight <dmerriman@gmail.com> | 2008-06-18 17:34:14 -0400 |
commit | 5d2cdfbad07ca56bef939b44eea3599cbd043835 (patch) | |
tree | 67c496ff6ed5472298a98b52b2b0b1247128a599 | |
parent | f1b1ff1f7938fdcc662f4e1612aaf3f54415d5b7 (diff) | |
download | mongo-5d2cdfbad07ca56bef939b44eea3599cbd043835.tar.gz |
replay
-rw-r--r-- | db/db.cpp | 15 | ||||
-rw-r--r-- | db/query.cpp | 13 |
2 files changed, 25 insertions, 3 deletions
diff --git a/db/db.cpp b/db/db.cpp index 6530090c4f5..22741227c77 100644 --- a/db/db.cpp +++ b/db/db.cpp @@ -286,9 +286,10 @@ public: /* versions 114 bad memory bug fixed + 115 replay, opLogging */ void listen(int port) { - const char *Version = "db version: 114 11jun2008"; + const char *Version = "db version: 115 18jun2008"; problem() << Version << endl; cout << Version << endl; pdfileInit(); @@ -416,6 +417,12 @@ void jniCallback(Message& m, Message& out) } } +/* 0 = off; 1 = writes, 2 = reads, 3 = both */ +int opLogging = 0; +ofstream oplog("oplog.bin", ios::out | ios::binary); +#define OPWRITE if( opLogging & 1 ) oplog.write((char *) m.data, m.data->len); +#define OPREAD if( opLogging & 2 ) oplog.write((char *) m.data, m.data->len); + void connThread() { try { @@ -474,9 +481,11 @@ void connThread() } } else if( m.data->operation == dbQuery ) { + OPREAD; receivedQuery(dbMsgPort, m, ss); } else if( m.data->operation == dbInsert ) { + OPWRITE; try { ss << "insert "; receivedInsert(m, ss); @@ -488,6 +497,7 @@ void connThread() } } else if( m.data->operation == dbUpdate ) { + OPWRITE; try { ss << "update "; receivedUpdate(m, ss); @@ -499,6 +509,7 @@ void connThread() } } else if( m.data->operation == dbDelete ) { + OPWRITE; try { ss << "remove "; receivedDelete(m); @@ -510,11 +521,13 @@ void connThread() } } else if( m.data->operation == dbGetMore ) { + OPREAD; log = true; ss << "getmore "; receivedGetMore(dbMsgPort, m, ss); } else if( m.data->operation == dbKillCursors ) { + OPREAD; try { log = true; ss << "killcursors "; diff --git a/db/query.cpp b/db/query.cpp index 1f39854a4a5..cf066b4275f 100644 --- a/db/query.cpp +++ b/db/query.cpp @@ -457,6 +457,9 @@ bool dbEval(JSObj& cmd, JSObjBuilder& result) { return true; } +extern int opLogging; +extern ofstream oplog; + // e.g. // system.cmd$.find( { queryTraceLevel: 2 } ); // @@ -497,9 +500,15 @@ inline bool _runCommands(const char *ns, JSObj& jsobj, stringstream& ss, BufBuil } } else { - if( strncmp(ns, "admin", p-ns) != 0 ) // admin only + // admin only commands. + if( strncmp(ns, "admin", p-ns) != 0 ) return false; - if( strcmp(e.fieldName(),"queryTraceLevel") == 0 ) { + if( strcmp(e.fieldName(),"opLogging") == 0 ) { + valid = ok = true; + opLogging = (int) e.number(); + oplog.flush(); + cout << "CMD: opLogging set to " << opLogging << endl; + } else if( strcmp(e.fieldName(),"queryTraceLevel") == 0 ) { valid = ok = true; queryTraceLevel = (int) e.number(); } else if( strcmp(e.fieldName(),"traceAll") == 0 ) { |