void LogEngine::logSystemEvent(bool active, Logging::LoggingLevel level) { LogEntry entry(level, Logging::LoggingSourceSystem); entry.setActive(active); appendLogEntry(entry); emit logEntryAdded(entry); }
void LogEngine::logRuleTriggered(const Rule &rule) { LogEntry entry(Logging::LoggingSourceRules); entry.setTypeId(rule.id()); appendLogEntry(entry); emit logEntryAdded(entry); }
void LogEngine::logRuleActiveChanged(const Rule &rule) { LogEntry entry(Logging::LoggingSourceRules); entry.setTypeId(rule.id()); entry.setActive(rule.active()); appendLogEntry(entry); emit logEntryAdded(entry); }
void LogEngine::logAction(const Action &action, Logging::LoggingLevel level, int errorCode) { QStringList valueList; foreach (const Param ¶m, action.params()) { valueList << param.value().toString(); } LogEntry entry(level, Logging::LoggingSourceActions, errorCode); entry.setTypeId(action.actionTypeId()); entry.setDeviceId(action.deviceId()); entry.setValue(valueList.join(", ")); appendLogEntry(entry); emit logEntryAdded(entry); }
void Logger::addEntry(QString errorMessage) { QString ss; _strdate(m_dateStr); _strtime(m_timeStr); ss.append(m_dateStr); ss.append(" - "); ss.append(m_timeStr); ss.append(": "); ss.append(errorMessage); SLoggerLock->lock(); logEntries->push_back(ss); SLoggerLock->unlock(); emit logEntryAdded(); }
DlgViewLog::DlgViewLog(QWidget *parent) : QDialog(parent) { logArea = new QPlainTextEdit; logArea->setReadOnly(true); auto *mainLayout = new QVBoxLayout; mainLayout->addWidget(logArea); coClearLog = new QCheckBox; coClearLog->setText(tr("Clear log when closing")); coClearLog->setChecked(settingsCache->servers().getClearDebugLogStatus(true)); connect(coClearLog, SIGNAL(toggled(bool)), this, SLOT(actCheckBoxChanged(bool))); mainLayout->addWidget(coClearLog); setLayout(mainLayout); setWindowTitle(tr("Debug Log")); resize(800, 500); loadInitialLogBuffer(); connect(&Logger::getInstance(), SIGNAL(logEntryAdded(QString)), this, SLOT(logEntryAdded(QString))); }
void LogEngine::logEvent(const Event &event) { QStringList valueList; Logging::LoggingSource sourceType; if (event.isStateChangeEvent()) { sourceType = Logging::LoggingSourceStates; valueList << event.param("value").value().toString(); } else { sourceType = Logging::LoggingSourceEvents; foreach (const Param ¶m, event.params()) { valueList << param.value().toString(); } } LogEntry entry(sourceType); entry.setTypeId(event.eventTypeId()); entry.setDeviceId(event.deviceId()); entry.setValue(valueList.join(", ")); appendLogEntry(entry); emit logEntryAdded(entry); }
void LogEngine::appendLogEntry(const LogEntry &entry) { checkDBSize(); QString queryString = QString("INSERT INTO entries (timestamp, loggingEventType, loggingLevel, sourceType, typeId, deviceId, value, active, errorCode) values ('%1', '%2', '%3', '%4', '%5', '%6', '%7', '%8', '%9');") .arg(entry.timestamp().toTime_t()) .arg(entry.eventType()) .arg(entry.level()) .arg(entry.source()) .arg(entry.typeId().toString()) .arg(entry.deviceId().toString()) .arg(entry.value()) .arg(entry.active()) .arg(entry.errorCode()); QSqlQuery query; if (!query.exec(queryString)) { qCWarning(dcLogEngine) << "Error writing log entry. Driver error:" << query.lastError().driverText() << "Database error:" << query.lastError().databaseText(); qCWarning(dcLogEngine) << entry; return; } emit logEntryAdded(entry); }
void DlgViewLog::loadInitialLogBuffer() { QList<QString> logBuffer = Logger::getInstance().getLogBuffer(); foreach(QString message, logBuffer) logEntryAdded(message); }