11 LogMessage::LogMessage(
const QtMsgType type,
const QString& message, QHash<QString, QString>* logVars,
const QString &file,
const QString &
function,
const int line)
16 this->
function=
function;
31 QString decorated=msgFormat+
"\n";
32 decorated.replace(
"{msg}",
message);
34 if (decorated.contains(
"{timestamp}"))
36 decorated.replace(
"{timestamp}",
timestamp.toString(timestampFormat));
41 decorated.replace(
"{typeNr}",typeNr);
46 decorated.replace(
"{type}",
"(D)");
49 decorated.replace(
"{type}",
"(W)");
52 decorated.replace(
"{type}",
"(C)");
55 decorated.replace(
"{type}",
"(F)");
57 #if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)) 59 decorated.replace(
"{type}",
"(I)");
63 decorated.replace(
"{type}",typeNr);
66 decorated.replace(
"{file}",
file);
67 decorated.replace(
"{function}",
function);
68 decorated.replace(
"{line}",QString::number(
line));
71 threadId.setNum((std::size_t)QThread::currentThreadId());
72 decorated.replace(
"{thread}",threadId);
75 if (decorated.contains(
"{") && !
logVars.isEmpty())
77 QList<QString> keys=
logVars.keys();
78 foreach (QString key, keys)
80 decorated.replace(
"{"+key+
"}",
logVars.value(key));
QHash< QString, QString > logVars
LogMessage(const QtMsgType type, const QString &message, QHash< QString, QString > *logVars, const QString &file, const QString &function, const int line)
QtMsgType getType() const
QString toString(const QString &msgFormat, const QString ×tampFormat) const