Make logging of source function optional

This commit is contained in:
BlackMark 2020-07-04 18:08:38 +02:00
parent 4a2590ff0e
commit c86ec41b75

View File

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