| 27 | static QMutex mutex; |
| 28 | |
| 29 | QString formatFrameworkLogOut(QtMsgType type, const QMessageLogContext &context, const QString &msg) |
| 30 | { |
| 31 | auto fileNameList = QString(context.file).split(QDir::separator()); |
| 32 | auto currentName = fileNameList[fileNameList.size() - 1]; |
| 33 | |
| 34 | if (type == QtMsgType::QtDebugMsg) |
| 35 | return "[" + QString(context.category) + "][" |
| 36 | + LogUtils::localDateTime() + "][Debug][" |
| 37 | + currentName + " " |
| 38 | + context.function + " " |
| 39 | + QString::number(context.line) + "]" |
| 40 | + msg; |
| 41 | if (type == QtMsgType::QtInfoMsg) |
| 42 | return "[" + QString(context.category) + "][" |
| 43 | + LogUtils::localDateTime() + "][Info][" |
| 44 | + currentName + " " |
| 45 | + context.function + " " |
| 46 | + QString::number(context.line) + "]" |
| 47 | + msg; |
| 48 | if (type == QtMsgType::QtCriticalMsg) |
| 49 | return "[" + QString(context.category) + "][" |
| 50 | + LogUtils::localDateTime() + "][Critical][" |
| 51 | + currentName + " " |
| 52 | + context.function + " " |
| 53 | + QString::number(context.line) + "]" |
| 54 | + msg; |
| 55 | if (type == QtMsgType::QtWarningMsg) |
| 56 | return "[" + QString(context.category) + "][" |
| 57 | + LogUtils::localDateTime() + "][Warning][" |
| 58 | + currentName + " " |
| 59 | + context.function + " " |
| 60 | + QString::number(context.line) + "]" |
| 61 | + msg; |
| 62 | if (type == QtMsgType::QtSystemMsg) |
| 63 | return "[" + QString(context.category) + "][" |
| 64 | + LogUtils::localDateTime() + "][System][" |
| 65 | + currentName + " " |
| 66 | + context.function + " " |
| 67 | + QString::number(context.line) + "]" |
| 68 | + msg; |
| 69 | if (type == QtMsgType::QtFatalMsg) |
| 70 | return "[" + QString(context.category) + "][" |
| 71 | + LogUtils::localDateTime() + "][Fatal][" |
| 72 | + currentName + " " |
| 73 | + context.function + " " |
| 74 | + QString::number(context.line) + "]" |
| 75 | + msg; |
| 76 | return msg; |
| 77 | } |
| 78 | |
| 79 | static void rmExpiredLogs() |
| 80 | { |
no test coverage detected