some profiling management cleaning pre SERVER-456

This commit is contained in:
Eliot Horowitz
2009-12-29 12:08:13 -05:00
parent 3fd317da0a
commit 3b37c3fbd4
4 changed files with 37 additions and 12 deletions

View File

@@ -24,4 +24,32 @@ namespace mongo {
bool Database::_openAllFiles = false;
bool Database::setProfilingLevel( int newLevel , string& errmsg ){
if ( profile == newLevel )
return true;
if ( newLevel < 0 || newLevel > 2 ){
errmsg = "profiling level has to be >=0 and <= 2";
return false;
}
if ( newLevel == 0 ){
profile = 0;
return true;
}
assert( cc().database() == this );
if ( ! nsdetails( profileName.c_str() ) ){
BSONObjBuilder spec;
spec.appendBool( "capped", true );
spec.append( "size", 131072.0 );
if ( ! userCreateNS( profileName.c_str(), spec.done(), errmsg , true ) ){
return false;
}
}
profile = newLevel;
return true;
}
} // namespace mongo