diff --git a/example/src/helper/Log.cpp b/example/src/helper/Log.cpp index 07f42dcb..ba98deec 100644 --- a/example/src/helper/Log.cpp +++ b/example/src/helper/Log.cpp @@ -29,8 +29,22 @@ static bool g_logError = false; static std::unique_ptr g_logFile = nullptr; static std::unique_ptr g_logStream = nullptr; +static int g_logLevel = 4; + +std::map logLevelMap = { + {QtFatalMsg,0}, + {QtCriticalMsg,1}, + {QtWarningMsg,2}, + {QtInfoMsg,3}, + {QtDebugMsg,4} +}; + + static inline void myMessageHandler(const QtMsgType type, const QMessageLogContext &context, const QString &message) { + if(logLevelMap[type]>g_logLevel){ + return; + } if (context.file && !message.isEmpty()) { std::string strFileTmp = context.file; const char* ptr = strrchr(strFileTmp.c_str(), '/'); @@ -116,20 +130,20 @@ void Log::setup(const QString &app) } g_file_path = logDir.filePath(logFileName); qInstallMessageHandler(myMessageHandler); - qDebug()<