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

replay better

This commit is contained in:
Dwight 2008-06-23 16:28:25 -04:00
parent 5d2cdfbad0
commit cb18407a0d
4 changed files with 31 additions and 7 deletions

View File

@ -289,7 +289,7 @@ public:
115 replay, opLogging
*/
void listen(int port) {
const char *Version = "db version: 115 18jun2008";
const char *Version = "db version: 116 23jun2008";
problem() << Version << endl;
cout << Version << endl;
pdfileInit();
@ -418,8 +418,19 @@ 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);
int opLogging = 1;
//int opLogging = 0;
struct OpLog {
ofstream *f;
OpLog() {
stringstream ss;
ss << "oplog." << hex << time(0);
string name = ss.str();
f = new ofstream(name.c_str(), ios::out | ios::binary);
}
} _oplog;
void flushOpLog() { _oplog.f->flush(); }
#define oplog (*(_oplog.f))
#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);
@ -690,6 +701,9 @@ void initAndListen(int listenPort, const char *dbPath, const char *appserverLoc
int main(int argc, char* argv[], char *envp[] )
{
if( opLogging )
cout << "WARNING: this build has oplog enabled at startup. opLogging=" << opLogging << endl;
#if !defined(_WIN32)
signal(SIGPIPE, pipeSigHandler);
#endif
@ -778,7 +792,7 @@ int main(int argc, char* argv[], char *envp[] )
initAndListen(port, dbpath, appsrvPath);
goingAway = true;
return 0;
exit(0);
}
cout << "usage:\n";
@ -801,3 +815,10 @@ int main(int argc, char* argv[], char *envp[] )
// return _tmain(argc, 0);
//}
//#endif
#undef exit
void dbexit(int rc) {
flushOpLog();
exit(rc);
}

View File

@ -43,7 +43,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="&quot;C:\Program Files\Java\jdk1.6.0_05\include&quot;;&quot;C:\Program Files\Java\jdk1.6.0_05\include\win32&quot;"
AdditionalIncludeDirectories="&quot;..\pcre-7.4&quot;;..\boost;&quot;C:\Program Files\Java\jdk1.6.0_05\include&quot;;&quot;C:\Program Files\Java\jdk1.6.0_05\include\win32&quot;"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_SCL_SECURE_NO_DEPRECATE;BOOST_ALL_NO_LIB;BOOST_LIB_DIAGNOSTIC;_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H"
MinimalRebuild="true"
BasicRuntimeChecks="3"

View File

@ -458,7 +458,7 @@ bool dbEval(JSObj& cmd, JSObjBuilder& result) {
}
extern int opLogging;
extern ofstream oplog;
void flushOpLog();
// e.g.
// system.cmd$.find( { queryTraceLevel: 2 } );
@ -506,7 +506,7 @@ inline bool _runCommands(const char *ns, JSObj& jsobj, stringstream& ss, BufBuil
if( strcmp(e.fieldName(),"opLogging") == 0 ) {
valid = ok = true;
opLogging = (int) e.number();
oplog.flush();
flushOpLog();
cout << "CMD: opLogging set to " << opLogging << endl;
} else if( strcmp(e.fieldName(),"queryTraceLevel") == 0 ) {
valid = ok = true;

View File

@ -129,3 +129,6 @@ inline void our_debug_free(void *p) {
}
#define free our_debug_free
#endif
void dbexit(int resultcode);
#define exit dbexit