本文整理汇总了C++中Exception::end方法的典型用法代码示例。如果您正苦于以下问题:C++ Exception::end方法的具体用法?C++ Exception::end怎么用?C++ Exception::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Exception
的用法示例。
在下文中一共展示了Exception::end方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lock
void
CacheLogger::tlog_push_message(LogLevel ll, struct timeval *t, const char *component, Exception &e)
{
if (log_level <= ll ) {
MutexLocker lock(mutex);
localtime_r(&t->tv_sec, now_s);
char *timestr;
if (asprintf(×tr, "%02d:%02d:%02d.%06ld", now_s->tm_hour,
now_s->tm_min, now_s->tm_sec, t->tv_usec) == -1) {
return;
}
for (Exception::iterator i = e.begin(); i != e.end(); ++i) {
CacheEntry e;
e.log_level = ll;
e.component = component;
e.time = *t;
e.timestr = timestr;
e.message = std::string("[EXCEPTION] ") + *i;
__messages.push_front(e);
++__num_entries;
}
free(timestr);
if (__num_entries > __max_num_entries) {
__num_entries = __max_num_entries;
__messages.resize(__max_num_entries);
}
}
}
示例2: fprintf
void
FileLogger::tlog_error(struct timeval *t, const char *component, Exception &e)
{
if ( log_level <= LL_ERROR ) {
mutex->lock();
localtime_r(&t->tv_sec, now_s);
for (Exception::iterator i = e.begin(); i != e.end(); ++i) {
fprintf(log_file, "%s %02d:%02d:%02d.%06ld %s [EXCEPTION]: ", "E", now_s->tm_hour,
now_s->tm_min, now_s->tm_sec, (long)t->tv_usec, component);
fprintf(log_file, "%s", *i);
fprintf(log_file, "\n");
}
fflush(log_file);
mutex->unlock();
}
}
示例3: gettimeofday
void
FileLogger::log_warn(const char *component, Exception &e)
{
if ( log_level <= LL_WARN ) {
struct timeval now;
gettimeofday(&now, NULL);
mutex->lock();
localtime_r(&now.tv_sec, now_s);
for (Exception::iterator i = e.begin(); i != e.end(); ++i) {
fprintf(log_file, "%s %02d:%02d:%02d.%06ld %s [EXCEPTION]: ", "W", now_s->tm_hour,
now_s->tm_min, now_s->tm_sec, (long)now.tv_usec, component);
fprintf(log_file, "%s", *i);
fprintf(log_file, "\n");
}
fflush(log_file);
mutex->unlock();
}
}