mirror of
https://github.com/YACReader/yacreader
synced 2025-07-18 21:14:33 -04:00
Updated loggin component of QtWebApp to version 1.6.5
This commit is contained in:
@ -6,7 +6,8 @@
|
||||
#include "logmessage.h"
|
||||
#include <QThread>
|
||||
|
||||
LogMessage::LogMessage(const QtMsgType type, const QString& message, QHash<QString, QString>* logVars, const QString &file, const QString &function, const int line) {
|
||||
LogMessage::LogMessage(const QtMsgType type, const QString& message, QHash<QString, QString>* logVars, const QString &file, const QString &function, const int line)
|
||||
{
|
||||
this->type=type;
|
||||
this->message=message;
|
||||
this->file=file;
|
||||
@ -17,16 +18,19 @@ LogMessage::LogMessage(const QtMsgType type, const QString& message, QHash<QStri
|
||||
|
||||
// Copy the logVars if not null,
|
||||
// so that later changes in the original do not affect the copy
|
||||
if (logVars) {
|
||||
if (logVars)
|
||||
{
|
||||
this->logVars=*logVars;
|
||||
}
|
||||
}
|
||||
|
||||
QString LogMessage::toString(const QString& msgFormat, const QString& timestampFormat) const {
|
||||
QString LogMessage::toString(const QString& msgFormat, const QString& timestampFormat) const
|
||||
{
|
||||
QString decorated=msgFormat+"\n";
|
||||
decorated.replace("{msg}",message);
|
||||
|
||||
if (decorated.contains("{timestamp}")) {
|
||||
if (decorated.contains("{timestamp}"))
|
||||
{
|
||||
decorated.replace("{timestamp}",timestamp.toString(timestampFormat));
|
||||
}
|
||||
|
||||
@ -34,21 +38,22 @@ QString LogMessage::toString(const QString& msgFormat, const QString& timestampF
|
||||
typeNr.setNum(type);
|
||||
decorated.replace("{typeNr}",typeNr);
|
||||
|
||||
switch (type) {
|
||||
case QtDebugMsg:
|
||||
decorated.replace("{type}","DEBUG");
|
||||
break;
|
||||
case QtWarningMsg:
|
||||
decorated.replace("{type}","WARNING");
|
||||
break;
|
||||
case QtCriticalMsg:
|
||||
decorated.replace("{type}","CRITICAL");
|
||||
break;
|
||||
case QtFatalMsg:
|
||||
decorated.replace("{type}","FATAL");
|
||||
break;
|
||||
default:
|
||||
decorated.replace("{type}",typeNr);
|
||||
switch (type)
|
||||
{
|
||||
case QtDebugMsg:
|
||||
decorated.replace("{type}","DEBUG");
|
||||
break;
|
||||
case QtWarningMsg:
|
||||
decorated.replace("{type}","WARNING");
|
||||
break;
|
||||
case QtCriticalMsg:
|
||||
decorated.replace("{type}","CRITICAL");
|
||||
break;
|
||||
case QtFatalMsg:
|
||||
decorated.replace("{type}","FATAL");
|
||||
break;
|
||||
default:
|
||||
decorated.replace("{type}",typeNr);
|
||||
}
|
||||
|
||||
decorated.replace("{file}",file);
|
||||
@ -60,9 +65,11 @@ QString LogMessage::toString(const QString& msgFormat, const QString& timestampF
|
||||
decorated.replace("{thread}",threadId);
|
||||
|
||||
// Fill in variables
|
||||
if (decorated.contains("{") && !logVars.isEmpty()) {
|
||||
if (decorated.contains("{") && !logVars.isEmpty())
|
||||
{
|
||||
QList<QString> keys=logVars.keys();
|
||||
foreach (QString key, keys) {
|
||||
foreach (QString key, keys)
|
||||
{
|
||||
decorated.replace("{"+key+"}",logVars.value(key));
|
||||
}
|
||||
}
|
||||
@ -70,6 +77,7 @@ QString LogMessage::toString(const QString& msgFormat, const QString& timestampF
|
||||
return decorated;
|
||||
}
|
||||
|
||||
QtMsgType LogMessage::getType() const {
|
||||
QtMsgType LogMessage::getType() const
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
Reference in New Issue
Block a user