本文整理汇总了C++中LogEntry类的典型用法代码示例。如果您正苦于以下问题:C++ LogEntry类的具体用法?C++ LogEntry怎么用?C++ LogEntry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LogEntry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: on_commit_fuse
// -----------------------------------------------------------------------------
void hub::on_commit_fuse(LogEntry entry) {
if (!entry.acked_by_quorum()) return;
auto new_graph = acks_to_graph(entry.acks);
_broadcast_routing_table->recalculate(new_graph);
LOG("Commit config: ", entry.message_id(), ": ", new_graph);
ASSERT(!_configs.empty());
auto prev_quorum = _configs.rbegin()->second;
Diff diff(prev_quorum, entry.quorum);
_configs.emplace(entry.message_id(), std::move(entry.quorum));
// Forget about the lost nodes
for (auto id : diff.removed) {
_seen->forget_messages_from_user(id);
_nodes.erase(id);
}
if (!diff.added.empty()) {
if (destroys_this([&]() { _callbacks->on_insert(move(diff.added)); })) {
return;
}
}
if (!diff.removed.empty()) {
if (destroys_this([&]() { _callbacks->on_remove(move(diff.removed)); })) {
return;
}
}
}
示例2: lock
void Log::clear(UINT32 channel)
{
RecursiveLock lock(mMutex);
Vector<LogEntry> newEntries;
for(auto& entry : mEntries)
{
if (entry.getChannel() == channel)
continue;
newEntries.push_back(entry);
}
mEntries = newEntries;
Queue<LogEntry> newUnreadEntries;
while (!mUnreadEntries.empty())
{
LogEntry entry = mUnreadEntries.front();
mUnreadEntries.pop();
if (entry.getChannel() == channel)
continue;
newUnreadEntries.push(entry);
}
mUnreadEntries = newUnreadEntries;
mHash++;
}
示例3: NextErrorCode
int LogTester::NextErrorCode()
{
LogEntry le;
while(mBuffer.ReadLog(le))
{
if(le.GetErrorCode() >= 0) return le.GetErrorCode();
}
return -1;
}
示例4: l
bool LogManager::Truncate(uint64_t index,uint64_t term){
abb::Mutex::Locker l(mtx_);
LOG(TRACE) << "log.truncate: " << index;
if(index < this->commit_index_){
LOG(DEBUG) << "log.truncate.before";
return false;
}
if(index > (log_entry_arr_.size() + start_index_)){
LOG(DEBUG) << "log.truncate.after" << index << ":"<< log_entry_arr_.size() << "+" << start_index_ << "commit_index:" << commit_index_;
return false;
}
if(index == this->start_index_){
lseek(fd_,0, SEEK_SET);
ftruncate(fd_,0);
for(unsigned st=0;st < this->log_entry_arr_.size() ;st++){
LogEntry* entry = log_entry_arr_[st];
if(entry->ev_){
if(entry->ev_){
entry->ev_->Notify(NULL,"command failed to be committed due to node failure");
entry->ev_->UnRef();
entry->ev_ = NULL;
}
entry->UnRef();
}
}
this->log_entry_arr_.clear();
}else{
if(index < (this->start_index_+this->log_entry_arr_.size()) ){
int st = index - this->start_index_ -1;
LogEntry* entry = this->log_entry_arr_[st];
if (this->log_entry_arr_.size()> 0 && entry->term_ != term ){
LOG(DEBUG) << "log.truncate.termMismatch";
return false;
}else{
int start = index - this->start_index_;
LogEntry* entry = this->log_entry_arr_[start];
ftruncate(fd_,entry->position);
lseek(fd_,entry->position, SEEK_SET);
for(int i=start;i < (int)this->log_entry_arr_.size();i++){
LogEntry* inentry = this->log_entry_arr_[i];
if(inentry){
if(inentry->ev_){
inentry->ev_->Notify(NULL,"command failed to be committed due to node failure");
inentry->ev_->UnRef();
inentry->ev_ = NULL;
}
inentry->UnRef();
}
}
this->log_entry_arr_.erase(this->log_entry_arr_.begin()+start,this->log_entry_arr_.end());
LOG(DEBUG) << "log.truncate.success" << this->start_index_ << "/" << this->log_entry_arr_.size();
}
}
}
return true;
}
示例5: ClearLog
int LogTester::ClearLog()
{
int max = -1;
LogEntry le;
while(mBuffer.ReadLog(le)) {
if(le.GetErrorCode() > max) max = le.GetErrorCode();
}
return max;
}
示例6: ClearLog
int LogTester::ClearLog()
{
int max = -1;
LogEntry le;
while(!mBuffer.empty()) {
if(mBuffer.front().GetErrorCode() > max) max = le.GetErrorCode();
mBuffer.pop();
}
return max;
}
示例7: NextErrorCode
int LogTester::NextErrorCode()
{
LogEntry le;
while(!mBuffer.empty()) {
le = mBuffer.front();
mBuffer.pop();
if(le.GetErrorCode() >= 0) {
return le.GetErrorCode();
}
}
return -1;
}
示例8: testWrite
void Datastore::testWrite(int n)
{
LogEntry le;
for (int i = 0; i < n; i++)
{
le.setPressure( i + 1 );
le.setTemperature( 2 * i + 1 );
le.setBattery( 0.1 * (double)(i + 1) );
// le.print();
addEntry(&le);
}
addFileEndMarker();
}
示例9: switch
void LogWindow::addLogEntry(const LogEntry &entry)
{
QString entryType;
QTextCharFormat *entryFormat;
switch (entry.entryType()) {
case LogEntry::DebugMessage:
entryType = tr("Debug");
entryFormat = m_debugMessageFormat;
break;
case LogEntry::Notification:
entryType = tr("Notification");
entryFormat = m_notificationFormat;
break;
case LogEntry::Warning:
entryType = tr("Warning");
entryFormat = m_warningFormat;
break;
case LogEntry::Error:
entryType = tr("Error");
entryFormat = m_errorFormat;
break;
default:
entryType = tr("LogEntry");
entryFormat = m_debugMessageFormat;
}
QTextDocument *doc = m_log->document();
QTextCursor cur(doc);
cur.beginEditBlock();
cur.movePosition(QTextCursor::Start);
cur.insertBlock(*m_logEntryBlockFormat);
cur.insertText(entry.timeStamp().toString("[yyyy-MM-dd hh:mm:ss]"),
*m_timeStampFormat);
cur.insertText(" ");
cur.insertText(QString("%1").arg(entryType, -12), *entryFormat);
cur.insertText(" ");
if (entry.moleQueueId() == InvalidId) {
cur.insertText(tr("Job %1").arg("N/A", -6), *m_moleQueueIdFormat);
}
else {
cur.insertText(tr("Job %1").arg(entry.moleQueueId(), -6),
*m_moleQueueIdFormat);
}
cur.insertText(" ");
// Modify newlines to align with the hanging indent.
cur.insertText(entry.message().replace(QRegExp("\\n+"), "\n "),
*m_messageFormat);
cur.endEditBlock();
}
示例10: hasValidExtension
bool LogAnalyser::hasValidExtension ( LogEntry& logEntry )
{
// L'extension est valide si on n'arrive pas à la trouver dans
// la liste des extensions exclues
return find( EXCLUDE_LIST.begin( ), EXCLUDE_LIST.end( ),
logEntry.GetUriExtension( ) ) == EXCLUDE_LIST.end( );
} //----- Fin de hasValidExtension
示例11: GetX509CertLogEntry
void
GetX509CertLogEntry(LogEntry& entry)
{
entry.Reset();
entry.type = ct::LogEntry::Type::X509;
entry.leafCertificate = HexToBytes(kDefaultDerCert);
}
示例12: PushItemsToFile
/**
open, write, close the file rather than hold it forever so it can handle having
the file deleted from underneath it without failing.
*/
void LogToFile :: PushItemsToFile()
{
try {
std::ofstream file(mFileName.c_str(), std::ios::app | std::ios::out);
if(!file.is_open()) std::cerr << "Failure to open: " << mFileName << std::endl;
LogEntry le;
while(ReadLog(le)) file << le.LogString() << std::endl;
file << std::flush;
if(file.bad()) std::cerr << "Failure during writing log file: " << file.rdstate() << std::endl;
file.close();
}
catch(std::exception e){
std::cerr << "Error during LogToFile: " << e.what() << std::endl;
}
}
示例13: GetPrecertLogEntry
void
GetPrecertLogEntry(LogEntry& entry)
{
entry.Reset();
entry.type = ct::LogEntry::Type::Precert;
entry.issuerKeyHash = HexToBytes(kDefaultIssuerKeyHash);
entry.tbsCertificate = HexToBytes(kDefaultDerTbsCert);
}
示例14: ErrorLog
VXIlogResult OSBlog::ErrorLog(const VXIchar* moduleName,
VXIunsigned errorID,
const VXIchar* format,
va_list args)
{
const VXIchar *finalModuleName =
(moduleName && moduleName[0] ? moduleName : L"UNKNOWN");
// Output the log message
LogEntry entry;
entry.AddEntrySep();
entry += channelNum;
entry.AddEntrySep();
entry += finalModuleName;
entry.AddEntrySep();
entry += errorID;
entry.AddEntrySep();
VXIlogResult rc = entry.AppendKeyValueVa(format, args);
entry.Terminate();
VXIlogResult rc2 = WriteEntry(entry);
if (rc2 != VXIlog_RESULT_SUCCESS)
rc = rc2;
// Want to warn the caller that NULL moduleName really isn't OK, but
// logged it anyway
if ((! moduleName) || (! moduleName[0]))
rc = VXIlog_RESULT_INVALID_ARGUMENT;
return rc;
}
示例15: timestamp
void StdLogOutput::print(const LogEntry &entry)
{
//const QString timestamp(entry.timestamp().toString("yy-MM-dd::hh:mm:ss"));
const QString timestamp(entry.timestamp().toString("hh:mm:ss"));
switch(entry.type())
{
case LogEntry::DEBUG_LOG:
std::cout << QString("%1 %2 %3: %4").arg(timestamp).arg(entry.file()).arg(entry.line()).arg(entry.message()).toStdString() << std::endl;
break;
case LogEntry::ERROR_LOG:
std::cout << QString("%1 error: %2").arg(timestamp).arg(entry.message()).toStdString() << std::endl;
break;
case LogEntry::INFORMATION_LOG:
case LogEntry::MESSAGE_LOG:
case LogEntry::WORKFLOW_LOG:
std::cout << QString("%1: %2").arg(timestamp).arg(entry.message()).toStdString() << std::endl;
break;
case LogEntry::WARNING_LOG:
std::cout << QString("%1 warning: %2").arg(timestamp).arg(entry.message()).toStdString() << std::endl;
break;
case LogEntry::EMPTYLINE_LOG:
std::cout << std::endl << std::endl;
break;
case LogEntry::UNDEFINED_LOG:
default:
break;
}
}