2
0
forked from Ivasoft/DSView

add: log class lib

This commit is contained in:
dreamsourcelabTAI
2022-07-08 19:35:38 +08:00
parent 9eab24aaa8
commit 94fddcdadc
10 changed files with 652 additions and 12407 deletions

View File

@@ -36,6 +36,7 @@
#include "pv/config/appconfig.h"
#include "config.h"
#include "pv/appcontrol.h"
#include "pv/log.h"
#ifdef _WIN32
#include <windows.h>
@@ -51,6 +52,7 @@ void usage()
"Help Options:\n"
" -l, --loglevel Set libsigrok/libsigrokdecode loglevel\n"
" -V, --version Show release version\n"
" -lf, --savelog save log to locale file\n"
" -h, -?, --help Show help option\n"
"\n", DS_BIN_NAME, DS_DESCRIPTION);
}
@@ -123,8 +125,13 @@ bool bHighScale = true;
QApplication::setOrganizationName("DreamSourceLab");
QApplication::setOrganizationDomain("www.DreamSourceLab.com");
qDebug()<<"\n----------------- version:"<<DS_VERSION_STRING<<"-----------------\n";
qDebug()<<"Qt:"<<QT_VERSION_STR;
dsv_log_init();
xlog_print(dsv_log, 3, NULL, "----------------- version:%s-----------------", DS_VERSION_STRING);
xlog_print(dsv_log, 3, NULL, "Qt:%s", QT_VERSION_STR);
//qDebug()<<"\n----------------- version:"<<DS_VERSION_STRING<<"-----------------\n";
//qDebug()<<"Qt:"<<QT_VERSION_STR;
#ifdef Q_OS_LINUX
// Use low version qt plugins, for able to debug
@@ -223,6 +230,7 @@ bool bHighScale = true;
//uninit
control->UnInit();
control->Destroy();
dsv_log_uninit();
return ret;
}

41
DSView/pv/log.cpp Normal file
View File

@@ -0,0 +1,41 @@
/*
* This file is part of the DSView project.
* DSView is based on PulseView.
*
* Copyright (C) 2022 DreamSourceLab <support@dreamsourcelab.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "log.h"
xlog_writer *dsv_log = nullptr;
xlog_context *log_ctx = nullptr;
void dsv_log_init()
{
if (log_ctx == nullptr){
log_ctx = xlog_new();
dsv_log = xlog_create_writer(log_ctx, "DSView");
}
}
void dsv_log_uninit()
{
xlog_free(log_ctx);
xlog_free_writer(dsv_log);
log_ctx = nullptr;
dsv_log = nullptr;
}

33
DSView/pv/log.h Normal file
View File

@@ -0,0 +1,33 @@
/*
* This file is part of the DSView project.
* DSView is based on PulseView.
*
* Copyright (C) 2022 DreamSourceLab <support@dreamsourcelab.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _DSV_LOG_H_
#define _DSV_LOG_H_
#include <common/log/xlog.h>
extern xlog_writer *dsv_log;
void dsv_log_init();
void dsv_log_uninit();
#endif