| 44 | } |
| 45 | |
| 46 | void |
| 47 | LogDialog::saveLog(QString path) |
| 48 | { |
| 49 | FILE *fp; |
| 50 | |
| 51 | if ((fp = fopen(path.toStdString().c_str(), "w")) == nullptr) { |
| 52 | QString error(errno); |
| 53 | |
| 54 | QMessageBox::critical( |
| 55 | this, |
| 56 | "Save message log", |
| 57 | "Failed to save message log to file: " + error + "\n\n"); |
| 58 | return; |
| 59 | } |
| 60 | |
| 61 | for (int i = 0; i < this->msgVec.size(); ++i) { |
| 62 | fprintf( |
| 63 | fp, |
| 64 | "%ld.%d,%s,%s,%s:%d,%s", |
| 65 | this->msgVec[i].time.tv_sec, |
| 66 | static_cast<int>(this->msgVec[i].time.tv_usec), |
| 67 | su_log_severity_to_string(this->msgVec[i].severity), |
| 68 | this->msgVec[i].domain.c_str(), |
| 69 | this->msgVec[i].function.c_str(), |
| 70 | this->msgVec[i].line, |
| 71 | this->msgVec[i].message.c_str()); |
| 72 | } |
| 73 | |
| 74 | fclose(fp); |
| 75 | } |
| 76 | |
| 77 | void |
| 78 | LogDialog::connectAll(void) |