diff options
author | Eliot Horowitz <eliot@10gen.com> | 2009-11-11 16:02:47 -0500 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2009-11-11 16:02:47 -0500 |
commit | 6f0dce36a5d60452d13cf6a5ab9a2276a6b77a32 (patch) | |
tree | edbe4a9bef22b52997deca49095f9cec161d464b /db/instance.h | |
parent | 4dae04b643b82466a23c2d565227fbce7bc1d9e6 (diff) | |
download | mongo-6f0dce36a5d60452d13cf6a5ab9a2276a6b77a32.tar.gz |
rename old oplog to diaglog - make it always compiled in
Diffstat (limited to 'db/instance.h')
-rw-r--r-- | db/instance.h | 44 |
1 files changed, 26 insertions, 18 deletions
diff --git a/db/instance.h b/db/instance.h index 7541dd99fb4..8ec00ef4f01 100644 --- a/db/instance.h +++ b/db/instance.h @@ -27,26 +27,23 @@ namespace mongo { -// turn on or off the oplog.* files which the db can generate. -// these files are for diagnostic purposes and are unrelated to -// local.oplog.$main used by replication. -// -#define OPLOG if( 0 ) - - int getOpLogging(); - extern string dbExecCommand; -#define OPWRITE if( getOpLogging() & 1 ) _oplog.write((char *) m.data, m.data->len); -#define OPREAD if( getOpLogging() & 2 ) _oplog.readop((char *) m.data, m.data->len); +#define OPWRITE if( _diaglog.level & 1 ) _diaglog.write((char *) m.data, m.data->len); +#define OPREAD if( _diaglog.level & 2 ) _diaglog.readop((char *) m.data, m.data->len); - struct OpLog { + struct DiagLog { ofstream *f; - OpLog() : f(0) { } + /* 0 = off; 1 = writes, 2 = reads, 3 = both + 7 = log a few reads, and all writes. + */ + int level; + DiagLog() : f(0) , level(0) { } void init() { - OPLOG { + if ( ! f && level ){ + log() << "diagLogging = " << level << endl; stringstream ss; - ss << "oplog." << hex << time(0); + ss << "diaglog." << hex << time(0); string name = ss.str(); f = new ofstream(name.c_str(), ios::out | ios::binary); if ( ! f->good() ) { @@ -55,15 +52,24 @@ namespace mongo { } } } + /** + * @return old + */ + int setLevel( int newLevel ){ + int old = level; + level = newLevel; + init(); + return old; + } void flush() { - OPLOG f->flush(); + if ( level ) f->flush(); } void write(char *data,int len) { - OPLOG f->write(data,len); + if ( level & 1 ) f->write(data,len); } void readop(char *data, int len) { - OPLOG { - bool log = (getOpLogging() & 4) == 0; + if ( level & 2 ) { + bool log = (level & 4) == 0; OCCASIONALLY log = true; if ( log ) f->write(data,len); @@ -71,6 +77,8 @@ namespace mongo { } }; + extern DiagLog _diaglog; + /* we defer response until we unlock. don't want a blocked socket to keep things locked. */ |