QString SimpleLayout::format(const LoggingEvent &rEvent) { if (mShowLevel) return rEvent.level().toString() + QLatin1String(" - ") + rEvent.message() + Layout::endOfLine(); else return rEvent.message() + Layout::endOfLine(); }
Filter::Decision StringMatchFilter::decide(const LoggingEvent &rEvent) const { if (rEvent.message().isEmpty() || mStringToMatch.isEmpty() || rEvent.message().indexOf(mStringToMatch) < 0) return Filter::NEUTRAL; if (mAcceptOnMatch) return Filter::ACCEPT; else return Filter::DENY; }
QSqlRecord DatabaseLayout::formatRecord(const LoggingEvent &rEvent) { QSqlField field; QSqlRecord record; if (!mTimeStamp.isEmpty()) { field.setName(mTimeStamp); field.setType(QVariant::DateTime); field.setGenerated(true); field.setValue(DateTime::fromMSecsSinceEpoch(rEvent.timeStamp())); record.append(field); } if (!mLoggerName.isEmpty()) { field.setName(mLoggerName); field.setType(QVariant::String); field.setGenerated(true); field.setValue(rEvent.loggerName()); record.append(field); } if (!mThreadName.isEmpty()) { field.setName(mThreadName); field.setType(QVariant::String); field.setGenerated(true); field.setValue(rEvent.threadName()); record.append(field); } if (!mLevel.isEmpty()) { field.setName(mLevel); field.setType(QVariant::String); field.setGenerated(true); field.setValue(rEvent.level().toString()); record.append(field); } if (!mMessage.isEmpty()) { field.setName(mMessage); field.setType(QVariant::String); field.setGenerated(true); field.setValue(rEvent.message()); record.append(field); } return record; }
QString BasicPatternConverter::convert(const LoggingEvent &rLoggingEvent) const { switch (mType) { case MESSAGE_CONVERTER: return rLoggingEvent.message(); break; case NDC_CONVERTER: return rLoggingEvent.ndc(); break; case LEVEL_CONVERTER: return rLoggingEvent.level().toString(); break; case THREAD_CONVERTER: return rLoggingEvent.threadName(); break; default: Q_ASSERT_X(false, "BasicPatternConverter::convert()", "Unkown type constant"); return QString(); } }
void BinaryWriterAppender::append(const LoggingEvent &rEvent) { // Q_ASSERT_X(, "WriterAppender::append()", "Lock must be held by caller"); if (const BinaryLoggingEvent *binEvent = dynamic_cast<const BinaryLoggingEvent *>(&rEvent)) *mpWriter << binEvent->binaryMessage(); else { if (Layout *l = layout()) { if (BinaryLayout *bl = qobject_cast<BinaryLayout*>(l)) *mpWriter << bl->binaryFormat(*binEvent); else *mpWriter << l->format(rEvent); } else *mpWriter << rEvent.message(); } if (handleIoErrors()) return; }