Add flag to log source location

This commit is contained in:
BlackMark 2020-07-05 11:14:46 +02:00
parent 3a88377f1d
commit 9099b4ead3

View File

@ -31,12 +31,13 @@ void logToFile(QtMsgType msgType, const QMessageLogContext& msgContext, const QS
break; break;
} }
#ifdef LOG_SOURCE_LOCATION
const auto msgFromFile = QString(msgContext.file); const auto msgFromFile = QString(msgContext.file);
const auto msgFromLine = (msgContext.line == 0) ? QString("") : QString("%1").arg(msgContext.line); const auto msgFromLine = (msgContext.line == 0) ? QString("") : QString("%1").arg(msgContext.line);
if(!msgFromFile.isEmpty() && !msgFromLine.isEmpty()) { if(!msgFromFile.isEmpty() && !msgFromLine.isEmpty()) {
formattedMsg += QString("[%1:%2] ").arg(msgContext.file).arg(msgContext.line); formattedMsg += QString("[%1:%2] ").arg(msgContext.file).arg(msgContext.line);
} }
#endif
#ifdef LOG_FUNCTION_LOCATION #ifdef LOG_FUNCTION_LOCATION
const auto msgFromFunction = QString(msgContext.function); const auto msgFromFunction = QString(msgContext.function);