Skip to content

Commit bfeea24

Browse files
committed
Add explicit log file upload on crash
1 parent 53575b7 commit bfeea24

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

src/core/management_layer/application_manager.cpp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,45 @@ void ApplicationManager::Implementation::sendCrashInfo()
664664
loader->addRequestAttribute("list_annotations", annotationsText);
665665
loader->addRequestAttributeFile("upload_file_minidump", dmpPath);
666666

667+
//
668+
// Прикрепляем лог-файл сессии, когда произошел краш
669+
//
670+
const QDateTime crashTime = QDateTime::fromSecsSinceEpoch(report.creation_time);
671+
const QDir logsDir(q->logFilePath());
672+
673+
QString previousSessionLogPath;
674+
if (logsDir.exists()) {
675+
QFileInfo bestLogFile;
676+
QDateTime bestLogTime;
677+
678+
const auto logFiles
679+
= logsDir.entryInfoList({ "*.log" }, QDir::Files, QDir::Time);
680+
for (const auto& logFile : logFiles) {
681+
const QDateTime logFileTime = logFile.lastModified();
682+
//
683+
// Ищем тот, который был изменен до времени краша, но максимально близко к
684+
// нему
685+
//
686+
if (logFileTime <= crashTime) {
687+
if (bestLogFile.filePath().isEmpty() || logFileTime > bestLogTime) {
688+
bestLogFile = logFile;
689+
bestLogTime = logFileTime;
690+
}
691+
}
692+
}
693+
694+
//
695+
// Если нашли подходящий файл, используем его
696+
//
697+
if (!bestLogFile.filePath().isEmpty() && bestLogFile.exists()) {
698+
previousSessionLogPath = bestLogFile.absoluteFilePath();
699+
}
700+
}
701+
702+
if (!previousSessionLogPath.isEmpty() && QFile::exists(previousSessionLogPath)) {
703+
loader->addRequestAttributeFile("upload_file_log", previousSessionLogPath);
704+
}
705+
667706
QObject::connect(loader, &NetworkRequest::downloadComplete,
668707
[dmpPath](const QByteArray& body, const QUrl&) {
669708
//

0 commit comments

Comments
 (0)