diff --git a/DSView/main.cpp b/DSView/main.cpp index 462d2b0c..cc430ea6 100644 --- a/DSView/main.cpp +++ b/DSView/main.cpp @@ -136,29 +136,8 @@ int main(int argc, char *argv[]) } else if (argcFinal - optind == 1){ open_file = argvFinal[argcFinal - 1]; - } - - //----------------------init log - dsv_log_init(); - - if (bStoreLog && logLevel < XLOG_LEVEL_DBG){ - logLevel = XLOG_LEVEL_DBG; } - if (logLevel != -1){ - dsv_log_level(logLevel); - } - - #ifdef DEBUG_INFO - if (XLOG_LEVEL_INFO > logLevel){ - dsv_log_level(XLOG_LEVEL_INFO); // on develop mode, set the default log ldevel - } - #endif - - if (bStoreLog){ - dsv_log_enalbe_logfile(); - } - //----------------------HightDpiScaling #if QT_VERSION >= QT_VERSION_CHECK(5,6,0) bool bHighScale = true; @@ -193,6 +172,26 @@ bool bHighScale = true; QApplication::setOrganizationName("DreamSourceLab"); QApplication::setOrganizationDomain("www.DreamSourceLab.com"); + //----------------------init log + dsv_log_init(); // Don't call before QApplication be inited + + if (bStoreLog && logLevel < XLOG_LEVEL_DBG){ + logLevel = XLOG_LEVEL_DBG; + } + if (logLevel != -1){ + dsv_log_level(logLevel); + } + + #ifdef DEBUG_INFO + if (XLOG_LEVEL_INFO > logLevel){ + dsv_log_level(XLOG_LEVEL_INFO); // on develop mode, set the default log ldevel + } + #endif + + if (bStoreLog){ + dsv_log_enalbe_logfile(); + } + //----------------------run dsv_info("----------------- version: %s-----------------", DS_VERSION_STRING); dsv_info("Qt:%s", QT_VERSION_STR); diff --git a/DSView/pv/log.cpp b/DSView/pv/log.cpp index 21dc3af5..75c38993 100644 --- a/DSView/pv/log.cpp +++ b/DSView/pv/log.cpp @@ -64,12 +64,15 @@ void dsv_log_enalbe_logfile() #ifdef Q_OS_LINUX lf = QDir::homePath() + "/DSView.log"; - #else - lf = GetAppDataDir() + "/DSView.log"; + #else + lf = tmp + GetAppDataDir() + "/DSView.log"; #endif - xlog_add_receiver_from_file(log_ctx, lf.toUtf8().data(), 0); - dsv_info("%s\"%s\"", "store log to file: ", lf.toUtf8().data()); + + int ret = xlog_add_receiver_from_file(log_ctx, lf.toUtf8().data(), 0); + if (ret != 0){ + dsv_err("%s", "create log file error!"); + } } } \ No newline at end of file