From: wsb Date: Fri, 10 Mar 2023 08:02:29 +0000 (+0800) Subject: 添加QsLog日志。 X-Git-Url: http://kyz.pub/gitweb/?a=commitdiff_plain;h=e37140c16b46707a53e0052c30eeea77b60e6a2e;p=zd%2Fzd-mcu.git 添加QsLog日志。 --- diff --git a/ZDBYQ/jiemian.pro b/ZDBYQ/jiemian.pro index 89f4b744..8d883002 100644 --- a/ZDBYQ/jiemian.pro +++ b/ZDBYQ/jiemian.pro @@ -8,7 +8,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += c++11 - +include(./QsLog/QsLog.pri) # The following define makes your compiler emit warnings if you use # any Qt feature that has been marked deprecated (the exact warnings # depend on your compiler). Please consult the documentation of the @@ -72,6 +72,11 @@ qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target +win32 { + LIBS += -lQsLog2 +} else { + LIBS += -lQsLog +} DISTFILES += \ C:/Users/Administrator/Desktop/微信截图_20220413180205.png \ diff --git a/ZDBYQ/jiemian.pro.user b/ZDBYQ/jiemian.pro.user index a8e912ac..3839e8cd 100644 --- a/ZDBYQ/jiemian.pro.user +++ b/ZDBYQ/jiemian.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId @@ -287,8 +287,9 @@ 2 - Qt4ProjectManager.Qt4RunConfiguration:C:/Users/Administrator/Desktop/0309/ZDBYQ/jiemian.pro - C:/Users/Administrator/Desktop/0309/ZDBYQ/jiemian.pro + jiemian2 + Qt4ProjectManager.Qt4RunConfiguration:E:/verygood/ZDBYQ/jiemian.pro + E:/verygood/ZDBYQ/jiemian.pro false diff --git a/ZDBYQ/mainwindow.cpp b/ZDBYQ/mainwindow.cpp index 51c269f3..3b3a042e 100644 --- a/ZDBYQ/mainwindow.cpp +++ b/ZDBYQ/mainwindow.cpp @@ -18,6 +18,7 @@ wangluo *wangluo_thread=nullptr; canshupeizhi *canshupeizhi_thread=nullptr; xitongshezhi *xitongshezhi_thread=nullptr; ModuleWifi * wifi=nullptr; +QsLogging::Logger &logger = QsLogging::Logger::instance(); QString Wireless="";//无线测温节点 uint8_t error_record_int=0;//错误文件日期 @@ -92,6 +93,14 @@ MainWindow::MainWindow(QWidget *parent) label_alarm_back->setGeometry(50,180,700,260); label_alarm_back->hide(); + logger.setLoggingLevel(QsLogging::TraceLevel); + + const QString sLogPath(QDir(QApplication::applicationDirPath()).filePath("data/log.txt")); + QsLogging::DestinationPtr fileDestination(QsLogging::DestinationFactory::MakeFileDestination( + sLogPath, QsLogging::EnableLogRotation, QsLogging::MaxSizeBytes(512*1024), QsLogging::MaxOldLogCount(5))); + logger.addDestination(fileDestination); + QLOG_TRACE() << "--trace msg MainWindow Constructor start"; + Pop_alarm_temp_A=new QPushButton(this); Pop_alarm_temp_A->setGeometry(60,190,110,30); Pop_alarm_temp_A->setStyleSheet("background: rgb(60, 135, 255);font: 12pt 黑体 bold"); @@ -288,6 +297,17 @@ MainWindow::MainWindow(QWidget *parent) wangluo_thread, SLOT(onWifiStateUpdate(bool))); connect(this, SIGNAL(sigWifiAutoConnect(QString , QString )), wifi, SLOT(onConnect(QString , QString ))); + + QLOG_TRACE() << "--trace msg MainWindow Constructor end"; + +// QLOG_TRACE() << "1-trace msg"; +// QLOG_DEBUG() << "2-debug msg"; +// QLOG_INFO() << "3-info msg"; +// QLOG_WARN() << "4-warn msg"; +// QLOG_ERROR() << "5-error msg"; +// QLOG_FATAL() << "6-fatal msg"; + + } MainWindow::~MainWindow() @@ -342,6 +362,7 @@ MainWindow::~MainWindow() chan12 = nullptr; } delete sharememery_test; + QsLogging::Logger::destroyInstance(); } void MainWindow::Mainwindows_Init() @@ -2855,14 +2876,17 @@ void MainWindow::label_0_9_clicked()//页面9label点击槽函数 void MainWindow::timerTimeout_share() { + QLOG_TRACE() << "--trace msg sharememery_test start"; share_num++; sharememery_test->lock(); memcpy(sharememery_test->data(), &share_num, sizeof(int)); sharememery_test->unlock(); + QLOG_TRACE() << "--trace msg sharememery_test end"; } void MainWindow::timerTimeout(void)//修改温度 { + QLOG_TRACE() << "--trace msg timerTimeout start"; bool ok; int led_data=0; @@ -2914,6 +2938,7 @@ void MainWindow::timerTimeout(void)//修改温度 QFile file_readtx1("/home/data/select_tiexin.txt");//文件路径 if(file_readtx1.open(QFile::ReadOnly)) { + QLOG_TRACE() << "--trace msg read /home/data/select_tiexin.txt "; QTextStream setWIFI_data(&file_readtx1); if(setWIFI_data.readLine() == "0") { @@ -3527,11 +3552,13 @@ label_alarm_back->hide(); Pop_alarm_fan->hide(); alarm_back_flag=false; } + QLOG_TRACE() << "--trace msg timerTimeout end"; } //uint8_t alarm_kaiji_count=0; void MainWindow::Sys_time(void)//系统时间 { + QLOG_TRACE() << "--trace msg Sys_time start"; rxy_count++; QFile file_read("/home/data/time"); @@ -3769,6 +3796,7 @@ void MainWindow::Sys_time(void)//系统时间 file_write_error.close(); } } + QLOG_TRACE() << "--trace msg Sys_time end"; } @@ -3779,8 +3807,10 @@ void MainWindow::Sys_time(void)//系统时间 void MainWindow::Lowpower_mode() { + QLOG_TRACE() << "--trace msg Lowpower_mode check start"; if(lowpower_mode_flag && !alarm_back_flag) { + QLOG_TRACE() << "--trace msg Lowpower_mode okkkkkkkkkk"; QApplication::setOverrideCursor(Qt::BlankCursor);//隐藏鼠标指针 timer1->stop(); tableView->hide(); @@ -3829,11 +3859,13 @@ void MainWindow::Lowpower_mode() } if(lowpower_mode_flag1) lowpower_mode_flag=true; + QLOG_TRACE() << "--trace msg Lowpower_mode check end"; } float A_vol2,B_vol3,C_vol3,A_Current3,B_Current3,C_Current2,A_PowerFactor3,B_PowerFactor3,C_PowerFactor2; void MainWindow::timerTimeout1(void)//参数修改 { + QLOG_TRACE() << "--trace msg timerTimeout1 start"; bool ok; main_set_back_color();//改背景色 @@ -4848,16 +4880,6 @@ void MainWindow::timerTimeout1(void)//参数修改 case 8://局放 { - if(kaiji_flag_ok && alarm_start) - { - - } - else - { - - - } - Qshare_memory_recive_cspz(); DisplayMsg_cspz(); label_cspz_2_1->setText("TEV峰值:"+QString::number(Cspz_TevTop_data1,'f',1)+"dB");//10进制转字符串 label_cspz_2_2->setText("TEV频次:"+QString::number(Cspz_TevFreq_data1,'f',1));//10进制转字符串 @@ -4955,11 +4977,13 @@ void MainWindow::timerTimeout1(void)//参数修改 setWIFI_data<<(QString::number(byq_data,'f',0)); } file_write.close(); + QLOG_TRACE() << "--trace msg timerTimeout1 end"; } bool alarm_pop=false; void MainWindow::timerTimeout2(void)//热像仪报警 { + QLOG_TRACE() << "--trace msg timerTimeout2 start"; if(alarm_pop)//报警弹窗背景 { alarm_pop=false; @@ -5143,6 +5167,7 @@ void MainWindow::timerTimeout2(void)//热像仪报警 } } } + QLOG_TRACE() << "--trace msg timerTimeout2 end"; } uint16_t jindutiao_count=20; @@ -5689,19 +5714,6 @@ float MainWindow::Qchange2(QString asend2) return aaa; } -void MainWindow::Qshare_memory_recive_cspz()//参数显示实时更新 -{ -// LCD_DATA_Struct_Cspz.Cspz_TevTop=ui_sharememory->read("TevTop"); -// LCD_DATA_Struct_Cspz.Cspz_TevFreq=ui_sharememory->read("TevFreq"); -// LCD_DATA_Struct_Cspz.Cspz_TevLevel=ui_sharememory->read("TevLevel"); -// LCD_DATA_Struct_Cspz.Cspz_TevAve=ui_sharememory->read("TevAve"); -// LCD_DATA_Struct_Cspz.Cspz_Tevperiodicity=ui_sharememory->read("Tevperiodicity"); -// LCD_DATA_Struct_Cspz.Cspz_UltTop=ui_sharememory->read("UltTop"); -// LCD_DATA_Struct_Cspz.Cspz_UltFreq=ui_sharememory->read("UltFreq"); -// LCD_DATA_Struct_Cspz.Cspz_UltLevel=ui_sharememory->read("UltLevel"); -// LCD_DATA_Struct_Cspz.Cspz_UltAve=ui_sharememory->read("UltAve"); -// LCD_DATA_Struct_Cspz.Cspz_UltEffective=ui_sharememory->read("UltEffective"); -} void MainWindow::Pop_alarm_door_Clicked() { @@ -5793,10 +5805,14 @@ void MainWindow::Pop_alarm_Wireless_Temperature_Clicked() lowpower_mode_flag=false; alarm_flag17=false; Pop_alarm_Wireless_Temperature->hide(); + + QLOG_TRACE() << "--trace msg Pop_alarm_Wireless_Temperature_Clicked start"; } void MainWindow::Pop_alarm_rxy_disconnect_Clicked() { + QLOG_TRACE() << "--trace msg Pop_alarm_rxy_disconnect_Clicked start"; + lowpower_mode_flag=false; if(alarm_start) { @@ -5804,6 +5820,7 @@ void MainWindow::Pop_alarm_rxy_disconnect_Clicked() if(file_write2.open(QFile::WriteOnly)) { QTextStream setWIFI_data(&file_write2); + QLOG_TRACE() << "--trace msg Pop_alarm_rxy_disconnect_Clicked creat /home/data/change_set.txt"; } file_write2.close(); @@ -5811,6 +5828,7 @@ void MainWindow::Pop_alarm_rxy_disconnect_Clicked() if(file_write3.open(QFile::WriteOnly)) { QTextStream setWIFI_data(&file_write3); + QLOG_TRACE() << "--trace msg Pop_alarm_rxy_disconnect_Clicked creat /home/data/change_set1.txt"; } file_write3.close(); //Pop_alarm_rxy_disconnect->hide(); @@ -5822,6 +5840,7 @@ void MainWindow::Pop_alarm_rxy_disconnect_Clicked() Pop_alarm_rxy_disconnect->hide(); } + QLOG_TRACE() << "--trace msg Pop_alarm_rxy_disconnect_Clicked end"; } @@ -5832,6 +5851,8 @@ void MainWindow::Pop_alarm_fan_Clicked() Pop_alarm_fan->hide(); QFile fileTemp("/home/data/Fanfail.txt"); fileTemp.remove(); + + QLOG_TRACE() << "--trace msg Pop_alarm_fan_Clicked start"; } void MainWindow::Pop_alarm_current_A_Clicked() @@ -5841,6 +5862,8 @@ void MainWindow::Pop_alarm_current_A_Clicked() Pop_alarm_current_A->hide(); QFile fileTemp("/home/data/Pop_reverseA.txt"); fileTemp.remove(); + + QLOG_TRACE() << "--trace msg Pop_alarm_current_A_Clicked start"; } void MainWindow::Pop_alarm_current_B_Clicked() @@ -5850,6 +5873,8 @@ void MainWindow::Pop_alarm_current_B_Clicked() Pop_alarm_current_B->hide(); QFile fileTemp("/home/data/Pop_reverseB.txt"); fileTemp.remove(); + + QLOG_TRACE() << "--trace msg Pop_alarm_current_B_Clicked start"; } void MainWindow::Pop_alarm_current_C_Clicked() @@ -5859,6 +5884,8 @@ void MainWindow::Pop_alarm_current_C_Clicked() Pop_alarm_current_C->hide(); QFile fileTemp("/home/data/Pop_reverseC.txt"); fileTemp.remove(); + + QLOG_TRACE() << "--trace msg Pop_alarm_current_C_Clicked start"; } void MainWindow::Pop_alarm_voltage_A_Clicked() @@ -5866,6 +5893,8 @@ void MainWindow::Pop_alarm_voltage_A_Clicked() lowpower_mode_flag=false; alarm_flag9=false; Pop_alarm_voltage_A->hide(); + + QLOG_TRACE() << "--trace msg Pop_alarm_voltage_A_Clicked start"; } void MainWindow::Pop_alarm_voltage_B_Clicked() @@ -5873,6 +5902,8 @@ void MainWindow::Pop_alarm_voltage_B_Clicked() lowpower_mode_flag=false; alarm_flag10=false; Pop_alarm_voltage_B->hide(); + + QLOG_TRACE() << "--trace msg Pop_alarm_voltage_B_Clicked start"; } void MainWindow::Pop_alarm_voltage_C_Clicked() @@ -5880,32 +5911,42 @@ void MainWindow::Pop_alarm_voltage_C_Clicked() lowpower_mode_flag=false; alarm_flag11=false; Pop_alarm_voltage_C->hide(); + + QLOG_TRACE() << "--trace msg Pop_alarm_voltage_C_Clicked start"; } void MainWindow::Pop_alarm_temp_A_Clicked() -{ +{ lowpower_mode_flag=false; alarm_flag12=false; Pop_alarm_temp_A->hide(); + + QLOG_TRACE() << "--trace msg Pop_alarm_temp_A_Clicked start"; } void MainWindow::Pop_alarm_temp_B_Clicked() -{ +{ lowpower_mode_flag=false; alarm_flag13=false; Pop_alarm_temp_B->hide(); + + QLOG_TRACE() << "--trace msg Pop_alarm_temp_B_Clicked start"; } void MainWindow::Pop_alarm_temp_C_Clicked() -{ +{ lowpower_mode_flag=false; alarm_flag14=false; Pop_alarm_temp_C->hide(); + + QLOG_TRACE() << "--trace msg Pop_alarm_temp_C_Clicked start"; } void MainWindow::Pop_alarm_temp_T_Clicked() -{ +{ lowpower_mode_flag=false; alarm_flag15=false; Pop_alarm_temp_T->hide(); + + QLOG_TRACE() << "--trace msg Pop_alarm_temp_T_Clicked start"; } diff --git a/ZDBYQ/mainwindow.h b/ZDBYQ/mainwindow.h index 7ee2b1bd..c441f534 100644 --- a/ZDBYQ/mainwindow.h +++ b/ZDBYQ/mainwindow.h @@ -48,6 +48,8 @@ #include "modulewifi.h" #include "modulesystime.h" #include "module4g.h" +#include "QsLog/include/QsLog.h" + #define LINUX 1 extern bool cspz_flag,wlpz_flag,xtpz_flag,alarm_start; @@ -60,7 +62,7 @@ extern xitongshezhi *xitongshezhi_thread; extern ModuleWifi * wifi; extern QString Wireless; extern uint8_t error_record_int;//错误文件日期 - +extern QsLogging::Logger &logger; QT_BEGIN_NAMESPACE namespace Ui { class MainWindow; } QT_END_NAMESPACE @@ -151,7 +153,6 @@ public: void label_8_show(int a); void label_9_show(int a); void DisplayMsg_cspz();//参数实时变换 - void Qshare_memory_recive_cspz(); void fun_4G_start();//4G模块加载 float Qchange(QString asend); float Qchange2(QString asend2); diff --git a/ZDBYQ/moc_applive.cpp b/ZDBYQ/moc_applive.cpp deleted file mode 100644 index 55672350..00000000 --- a/ZDBYQ/moc_applive.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/**************************************************************************** -** Meta object code from reading C++ file 'applive.h' -** -** Created by: The Qt Meta Object Compiler version 67 (Qt 5.6.2) -** -** WARNING! All changes made in this file will be lost! -*****************************************************************************/ - -#include "applive.h" -#include -#include -#if !defined(Q_MOC_OUTPUT_REVISION) -#error "The header file 'applive.h' doesn't include ." -#elif Q_MOC_OUTPUT_REVISION != 67 -#error "This file was generated using the moc from 5.6.2. It" -#error "cannot be used with the include files from this version of Qt." -#error "(The moc has changed too much.)" -#endif - -QT_BEGIN_MOC_NAMESPACE -struct qt_meta_stringdata_AppLive_t { - QByteArrayData data[6]; - char stringdata0[34]; -}; -#define QT_MOC_LITERAL(idx, ofs, len) \ - Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ - qptrdiff(offsetof(qt_meta_stringdata_AppLive_t, stringdata0) + ofs \ - - idx * sizeof(QByteArrayData)) \ - ) -static const qt_meta_stringdata_AppLive_t qt_meta_stringdata_AppLive = { - { -QT_MOC_LITERAL(0, 0, 7), // "AppLive" -QT_MOC_LITERAL(1, 8, 8), // "readData" -QT_MOC_LITERAL(2, 17, 0), // "" -QT_MOC_LITERAL(3, 18, 5), // "start" -QT_MOC_LITERAL(4, 24, 4), // "port" -QT_MOC_LITERAL(5, 29, 4) // "stop" - - }, - "AppLive\0readData\0\0start\0port\0stop" -}; -#undef QT_MOC_LITERAL - -static const uint qt_meta_data_AppLive[] = { - - // content: - 7, // revision - 0, // classname - 0, 0, // classinfo - 3, 14, // methods - 0, 0, // properties - 0, 0, // enums/sets - 0, 0, // constructors - 0, // flags - 0, // signalCount - - // slots: name, argc, parameters, tag, flags - 1, 0, 29, 2, 0x08 /* Private */, - 3, 1, 30, 2, 0x0a /* Public */, - 5, 0, 33, 2, 0x0a /* Public */, - - // slots: parameters - QMetaType::Void, - QMetaType::Bool, QMetaType::Int, 4, - QMetaType::Void, - - 0 // eod -}; - -void AppLive::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) -{ - if (_c == QMetaObject::InvokeMetaMethod) { - AppLive *_t = static_cast(_o); - Q_UNUSED(_t) - switch (_id) { - case 0: _t->readData(); break; - case 1: { bool _r = _t->start((*reinterpret_cast< int(*)>(_a[1]))); - if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; } break; - case 2: _t->stop(); break; - default: ; - } - } -} - -const QMetaObject AppLive::staticMetaObject = { - { &QObject::staticMetaObject, qt_meta_stringdata_AppLive.data, - qt_meta_data_AppLive, qt_static_metacall, Q_NULLPTR, Q_NULLPTR} -}; - - -const QMetaObject *AppLive::metaObject() const -{ - return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject; -} - -void *AppLive::qt_metacast(const char *_clname) -{ - if (!_clname) return Q_NULLPTR; - if (!strcmp(_clname, qt_meta_stringdata_AppLive.stringdata0)) - return static_cast(const_cast< AppLive*>(this)); - return QObject::qt_metacast(_clname); -} - -int AppLive::qt_metacall(QMetaObject::Call _c, int _id, void **_a) -{ - _id = QObject::qt_metacall(_c, _id, _a); - if (_id < 0) - return _id; - if (_c == QMetaObject::InvokeMetaMethod) { - if (_id < 3) - qt_static_metacall(this, _c, _id, _a); - _id -= 3; - } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { - if (_id < 3) - *reinterpret_cast(_a[0]) = -1; - _id -= 3; - } - return _id; -} -QT_END_MOC_NAMESPACE diff --git a/ZDBYQ/xitongshezhi.h b/ZDBYQ/xitongshezhi.h index 2f9fe394..c85cce1d 100644 --- a/ZDBYQ/xitongshezhi.h +++ b/ZDBYQ/xitongshezhi.h @@ -18,7 +18,7 @@ extern bool lowpower_mode_flag1; extern bool cspz_flag,wlpz_flag; -static QString version="软件版本号:A2023030902"; +static QString version="软件版本号:A20230310A"; namespace Ui { class xitongshezhi;