int main(int argc, char *argv[]) { QApplication a(argc, argv); qRegisterMetaType<mutrade::ExecutionReport>("mutrade::ExecutionReport"); qRegisterMetaType<mutrade::MarketData>("mutrade::MarketData"); QString logFile = "logs/"+QDateTime::currentDateTime().toString("yyyy-MM-dd-hh:mm:ss"); FileAppender* fileAppender = new FileAppender(logFile); Logger::registerAppender(fileAppender); fileAppender->setFormat("[%t] %m\n"); fileAppender->setDetailsLevel(Logger::Info); MainWindow w; QStringListModel *logModel = w.getListModel(); StringListModelAppender *stringListModelAppender = new StringListModelAppender(logModel); stringListModelAppender->setFormat("[%t] %m\n"); Logger::registerAppender(stringListModelAppender); LOGGER_INFO("Starting Application"); w.show(); return a.exec(); }
int main(int argc, char *argv[]) { QApplication app(argc, argv); //QTextCodec::setCodecForTr(QTextCodec::codecForName("utf-8")); QTextCodec::setCodecForLocale(QTextCodec::codecForName("utf-8")); appTitle = QObject::tr("凭证辅助处理系统"); QTranslator translator; //汉化标准对话框、标准上下文菜单等 translator.load("qt_zh_CN.qm","./translations"); //translator.load("i18n_zh"); //这个不行 app.installTranslator(&translator ); int errNum = appInit(); if(errNum != 0){ showErrorInfo(errNum); return errNum; } FileAppender* logFile = new FileAppender("./logs/app.log"); Logger::registerAppender(logFile); Logger::write(Logger::Must,"",0,"",""); Logger::write(Logger::Must,"",0,"", "************************************************************"); Logger::write(QDateTime::currentDateTime(), Logger::Must,"",0,"", QObject::tr("PzAssistant is starting......")); //qDebug()<<"qDebug export info!"; logLevel = AppConfig::getInstance()->getLogLevel(); logFile->setDetailsLevel(logLevel); MainWindow mainWin; mainWin.showMaximized(); mainWin.hideDockWindows(); mainWin.getMdiAreaSize(mdiAreaWidth, mdiAreaHeight); int exitCode = app.exec(); Logger::write(QDateTime::currentDateTime(),Logger::Must,"",0,"", QObject::tr("Quit PzAssistant!")); AppConfig::getInstance()->setLogLevel(logLevel); appExit(); return exitCode; }