本文整理汇总了C++中AssertionCount类的典型用法代码示例。如果您正苦于以下问题:C++ AssertionCount类的具体用法?C++ AssertionCount怎么用?C++ AssertionCount使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AssertionCount类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: regular
namespace mongo {
AssertionCount assertionCount;
AssertionCount::AssertionCount()
: regular(0),warning(0),msg(0),user(0),rollovers(0) {
}
void AssertionCount::rollover() {
rollovers++;
regular = 0;
warning = 0;
msg = 0;
user = 0;
}
void AssertionCount::condrollover( int newvalue ) {
static const int rolloverPoint = ( 1 << 30 );
if ( newvalue >= rolloverPoint )
rollover();
}
bool DBException::traceExceptions = false;
string DBException::toString() const {
stringstream ss; ss << getCode() << " " << what(); return ss.str();
return ss.str();
}
void DBException::traceIfNeeded( const DBException& e ) {
if( traceExceptions && ! inShutdown() ){
warning() << "DBException thrown" << causedBy( e ) << endl;
printStackTrace();
}
}
void ExceptionInfo::append( BSONObjBuilder& b , const char * m , const char * c ) const {
if ( msg.empty() )
b.append( m , "unknown assertion" );
else
b.append( m , msg );
if ( code )
b.append( c , code );
}
/* "warning" assert -- safe to continue, so we don't throw exception. */
NOINLINE_DECL void wasserted(const char *msg, const char *file, unsigned line) {
static bool rateLimited;
static time_t lastWhen;
static unsigned lastLine;
if( lastLine == line && time(0)-lastWhen < 5 ) {
if( !rateLimited ) {
rateLimited = true;
log() << "rate limiting wassert" << endl;
}
return;
}
lastWhen = time(0);
lastLine = line;
problem() << "warning assertion failure " << msg << ' ' << file << ' ' << dec << line << endl;
logContext();
setLastError(0,msg && *msg ? msg : "wassertion failure");
assertionCount.condrollover( ++assertionCount.warning );
#if defined(_DEBUG) || defined(_DURABLEDEFAULTON) || defined(_DURABLEDEFAULTOFF)
// this is so we notice in buildbot
log() << "\n\n***aborting after wassert() failure in a debug/test build\n\n" << endl;
abort();
#endif
}
NOINLINE_DECL void verifyFailed(const char *msg, const char *file, unsigned line) {
assertionCount.condrollover( ++assertionCount.regular );
problem() << "Assertion failure " << msg << ' ' << file << ' ' << dec << line << endl;
logContext();
setLastError(0,msg && *msg ? msg : "assertion failure");
stringstream temp;
temp << "assertion " << file << ":" << line;
AssertionException e(temp.str(),0);
breakpoint();
#if defined(_DEBUG) || defined(_DURABLEDEFAULTON) || defined(_DURABLEDEFAULTOFF)
// this is so we notice in buildbot
log() << "\n\n***aborting after verify() failure as this is a debug/test build\n\n" << endl;
abort();
#endif
throw e;
}
NOINLINE_DECL void fassertFailed( int msgid ) {
problem() << "Fatal Assertion " << msgid << endl;
logContext();
breakpoint();
log() << "\n\n***aborting after fassert() failure\n\n" << endl;
abort();
}
void uasserted(int msgid , const string &msg) {
uasserted(msgid, msg.c_str());
}
//.........这里部分代码省略.........
示例2: regular
namespace mongo {
AssertionCount assertionCount;
AssertionCount::AssertionCount()
: regular(0),warning(0),msg(0),user(0),rollovers(0){
}
void AssertionCount::rollover(){
rollovers++;
regular = 0;
warning = 0;
msg = 0;
user = 0;
}
void AssertionCount::condrollover( int newvalue ){
static int max = (int)pow( 2.0 , 30 );
if ( newvalue >= max )
rollover();
}
void ExceptionInfo::append( BSONObjBuilder& b , const char * m , const char * c ) const {
if ( msg.empty() )
b.append( m , "unknown assertion" );
else
b.append( m , msg );
if ( code )
b.append( c , code );
}
string getDbContext();
Assertion lastAssert[4];
/* "warning" assert -- safe to continue, so we don't throw exception. */
void wasserted(const char *msg, const char *file, unsigned line) {
problem() << "Assertion failure " << msg << ' ' << file << ' ' << dec << line << endl;
sayDbContext();
raiseError(0,msg && *msg ? msg : "wassertion failure");
lastAssert[1].set(msg, getDbContext().c_str(), file, line);
assertionCount.condrollover( ++assertionCount.warning );
}
void asserted(const char *msg, const char *file, unsigned line) {
assertionCount.condrollover( ++assertionCount.regular );
problem() << "Assertion failure " << msg << ' ' << file << ' ' << dec << line << endl;
sayDbContext();
raiseError(0,msg && *msg ? msg : "assertion failure");
lastAssert[0].set(msg, getDbContext().c_str(), file, line);
stringstream temp;
temp << "assertion " << file << ":" << line;
AssertionException e(temp.str(),0);
breakpoint();
throw e;
}
void uassert_nothrow(const char *msg) {
lastAssert[3].set(msg, getDbContext().c_str(), "", 0);
raiseError(0,msg);
}
void uasserted(int msgid, const char *msg) {
assertionCount.condrollover( ++assertionCount.user );
lastAssert[3].set(msg, getDbContext().c_str(), "", 0);
raiseError(msgid,msg);
throw UserException(msgid, msg);
}
void msgasserted(int msgid, const char *msg) {
assertionCount.condrollover( ++assertionCount.warning );
tlog() << "Assertion: " << msgid << ":" << msg << endl;
lastAssert[2].set(msg, getDbContext().c_str(), "", 0);
raiseError(msgid,msg && *msg ? msg : "massert failure");
breakpoint();
printStackTrace();
throw MsgAssertionException(msgid, msg);
}
void msgassertedNoTrace(int msgid, const char *msg) {
assertionCount.condrollover( ++assertionCount.warning );
log() << "Assertion: " << msgid << ":" << msg << endl;
lastAssert[2].set(msg, getDbContext().c_str(), "", 0);
raiseError(msgid,msg && *msg ? msg : "massert failure");
throw MsgAssertionException(msgid, msg);
}
void streamNotGood( int code , string msg , std::ios& myios ){
stringstream ss;
// errno might not work on all systems for streams
// if it doesn't for a system should deal with here
ss << msg << " stream invalid: " << errnoWithDescription();
throw UserException( code , ss.str() );
}
mongo::mutex *Assertion::_mutex = new mongo::mutex("Assertion");
string Assertion::toString() {
//.........这里部分代码省略.........
示例3: regular
namespace mongo {
AssertionCount assertionCount;
AssertionCount::AssertionCount()
: regular(0),warning(0),msg(0),user(0),rollovers(0) {
}
void AssertionCount::rollover() {
rollovers++;
regular = 0;
warning = 0;
msg = 0;
user = 0;
}
void AssertionCount::condrollover( int newvalue ) {
static int max = (int)pow( 2.0 , 30 );
if ( newvalue >= max )
rollover();
}
void ExceptionInfo::append( BSONObjBuilder& b , const char * m , const char * c ) const {
if ( msg.empty() )
b.append( m , "unknown assertion" );
else
b.append( m , msg );
if ( code )
b.append( c , code );
}
string getDbContext();
/* "warning" assert -- safe to continue, so we don't throw exception. */
void wasserted(const char *msg, const char *file, unsigned line) {
problem() << "warning Assertion failure " << msg << ' ' << file << ' ' << dec << line << endl;
sayDbContext();
raiseError(0,msg && *msg ? msg : "wassertion failure");
assertionCount.condrollover( ++assertionCount.warning );
#if defined(_DEBUG) || defined(_DURABLEDEFAULTON)
// this is so we notice in buildbot
log() << "\n\n***aborting after wassert() failure in a debug/test build\n\n" << endl;
abort();
#endif
}
void asserted(const char *msg, const char *file, unsigned line) {
assertionCount.condrollover( ++assertionCount.regular );
problem() << "Assertion failure " << msg << ' ' << file << ' ' << dec << line << endl;
sayDbContext();
raiseError(0,msg && *msg ? msg : "assertion failure");
stringstream temp;
temp << "assertion " << file << ":" << line;
AssertionException e(temp.str(),0);
breakpoint();
#if defined(_DEBUG) || defined(_DURABLEDEFAULTON)
// this is so we notice in buildbot
log() << "\n\n***aborting after assert() failure in a debug/test build\n\n" << endl;
abort();
#endif
throw e;
}
void uassert_nothrow(const char *msg) {
raiseError(0,msg);
}
void uasserted(int msgid, const char *msg) {
assertionCount.condrollover( ++assertionCount.user );
LOG(1) << "User Assertion: " << msgid << ":" << msg << endl;
raiseError(msgid,msg);
throw UserException(msgid, msg);
}
void msgasserted(int msgid, const char *msg) {
assertionCount.condrollover( ++assertionCount.warning );
tlog() << "Assertion: " << msgid << ":" << msg << endl;
raiseError(msgid,msg && *msg ? msg : "massert failure");
breakpoint();
printStackTrace();
throw MsgAssertionException(msgid, msg);
}
void msgassertedNoTrace(int msgid, const char *msg) {
assertionCount.condrollover( ++assertionCount.warning );
log() << "Assertion: " << msgid << ":" << msg << endl;
raiseError(msgid,msg && *msg ? msg : "massert failure");
throw MsgAssertionException(msgid, msg);
}
void streamNotGood( int code , string msg , std::ios& myios ) {
stringstream ss;
// errno might not work on all systems for streams
// if it doesn't for a system should deal with here
ss << msg << " stream invalid: " << errnoWithDescription();
throw UserException( code , ss.str() );
}
//.........这里部分代码省略.........
示例4: msgassertedNoTrace
void msgassertedNoTrace(int msgid, const char *msg) {
assertionCount.condrollover( ++assertionCount.warning );
log() << "Assertion: " << msgid << ":" << msg << endl;
lastAssert[2].set(msg, getDbContext().c_str(), "", 0);
raiseError(msgid,msg && *msg ? msg : "massert failure");
throw MsgAssertionException(msgid, msg);
}
示例5: wasserted
/*
* Johnny NOINLINE_DECL: do not treat function as inline function.
* Why?
*
* Pay attention to rate limit, why? this calls a lot?
*/
NOINLINE_DECL void wasserted(const char *msg, const char *file, unsigned line) {
static bool rateLimited;
static time_t lastWhen;
static unsigned lastLine;
if( lastLine == line && time(0)-lastWhen < 5 ) {
if( !rateLimited ) {
rateLimited = true;
log() << "rate limiting wassert" << endl;
}
return;
}
lastWhen = time(0);
lastLine = line;
problem() << "warning assertion failure " << msg << ' ' << file << ' ' << dec << line << endl;
// Johnny log context? can't find where.
logContext();
// Johnny set last error
setLastError(0,msg && *msg ? msg : "wassertion failure");
assertionCount.condrollover( ++assertionCount.warning );
#if defined(_DEBUG) || defined(_DURABLEDEFAULTON) || defined(_DURABLEDEFAULTOFF)
// this is so we notice in buildbot
log() << "\n\n***aborting after wassert() failure in a debug/test build\n\n" << endl;
abort();
#endif
}
示例6: wasserted
/* "warning" assert -- safe to continue, so we don't throw exception. */
void wasserted(const char *msg, const char *file, unsigned line) {
problem() << "Assertion failure " << msg << ' ' << file << ' ' << dec << line << endl;
sayDbContext();
raiseError(0,msg && *msg ? msg : "wassertion failure");
lastAssert[1].set(msg, getDbContext().c_str(), file, line);
assertionCount.condrollover( ++assertionCount.warning );
}
示例7: msgasserted
NOINLINE_DECL void msgasserted(int msgid, const char* msg) {
assertionCount.condrollover(++assertionCount.warning);
log() << "Assertion: " << msgid << ":" << msg << endl;
// breakpoint();
logContext();
throw MsgAssertionException(msgid, msg);
}
示例8: msgasserted
NOINLINE_DECL void msgasserted(int msgid, const char *msg) {
assertionCount.condrollover( ++assertionCount.warning );
tlog() << "Assertion: " << msgid << ":" << msg << endl;
setLastError(msgid,msg && *msg ? msg : "massert failure");
//breakpoint();
logContext();
throw MsgAssertionException(msgid, msg);
}
示例9: msgasserted
NOINLINE_DECL void msgasserted(int msgid, const char *msg) {
assertionCount.condrollover( ++assertionCount.warning );
tlog() << "Assertion: " << msgid << ":" << msg << endl;
raiseError(msgid,msg && *msg ? msg : "massert failure");
breakpoint();
printStackTrace();
throw MsgAssertionException(msgid, msg);
}
示例10: uassertedWithLocation
NOINLINE_DECL void uassertedWithLocation(int msgid,
const char* msg,
const char* file,
unsigned line) {
assertionCount.condrollover(++assertionCount.user);
LOG(1) << "User Assertion: " << msgid << ":" << redact(msg) << ' ' << file << ' ' << dec << line
<< endl;
throw UserException(msgid, msg);
}
示例11: msgassertedNoTraceWithLocation
NOINLINE_DECL void msgassertedNoTraceWithLocation(int msgid,
const char* msg,
const char* file,
unsigned line) {
assertionCount.condrollover(++assertionCount.warning);
log() << "Assertion: " << msgid << ":" << redact(msg) << ' ' << file << ' ' << dec << line
<< endl;
throw MsgAssertionException(msgid, msg);
}
示例12: wasserted
/* "warning" assert -- safe to continue, so we don't throw exception. */
void wasserted(const char *msg, const char *file, unsigned line) {
problem() << "warning Assertion failure " << msg << ' ' << file << ' ' << dec << line << endl;
sayDbContext();
raiseError(0,msg && *msg ? msg : "wassertion failure");
assertionCount.condrollover( ++assertionCount.warning );
#if defined(_DEBUG) || defined(_DURABLEDEFAULTON)
// this is so we notice in buildbot
log() << "\n\n***aborting after wassert() failure in a debug/test build\n\n" << endl;
abort();
#endif
}
示例13: asserted
void asserted(const char *msg, const char *file, unsigned line) {
assertionCount.condrollover( ++assertionCount.regular );
problem() << "Assertion failure " << msg << ' ' << file << ' ' << dec << line << endl;
sayDbContext();
raiseError(0,msg && *msg ? msg : "assertion failure");
lastAssert[0].set(msg, getDbContext().c_str(), file, line);
stringstream temp;
temp << "assertion " << file << ":" << line;
AssertionException e(temp.str(),0);
breakpoint();
throw e;
}
示例14: verifyFailed
NOINLINE_DECL void verifyFailed(const char* expr, const char* file, unsigned line) {
assertionCount.condrollover(++assertionCount.regular);
log() << "Assertion failure " << expr << ' ' << file << ' ' << dec << line << endl;
logContext();
stringstream temp;
temp << "assertion " << file << ":" << line;
AssertionException e(temp.str(), 0);
breakpoint();
#if defined(MONGO_CONFIG_DEBUG_BUILD)
// this is so we notice in buildbot
log() << "\n\n***aborting after verify() failure as this is a debug/test build\n\n" << endl;
quickExit(EXIT_ABRUPT);
#endif
throw e;
}
示例15: verifyFailed
NOINLINE_DECL void verifyFailed(const char *msg, const char *file, unsigned line) {
assertionCount.condrollover( ++assertionCount.regular );
log() << "Assertion failure " << msg << ' ' << file << ' ' << dec << line << endl;
logContext();
stringstream temp;
temp << "assertion " << file << ":" << line;
AssertionException e(temp.str(),0);
breakpoint();
#if defined(_DEBUG) || defined(_DURABLEDEFAULTON) || defined(_DURABLEDEFAULTOFF)
// this is so we notice in buildbot
log() << "\n\n***aborting after verify() failure as this is a debug/test build\n\n" << endl;
abort();
#endif
throw e;
}