Skip to content

Commit

Permalink
replace qdebug with boost.log
Browse files Browse the repository at this point in the history
  • Loading branch information
zhang-ray committed Nov 5, 2018
1 parent 0ad2e37 commit 2658989
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 15 deletions.
7 changes: 1 addition & 6 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@ image: Visual Studio 2015

before_build:
- git clone https://github.com/zhang-ray/audio-processing-module
#- cmd: tree /F C:\Libraries\boost_1_67_0
#- cmd: tree /F C:\Qt\5.11.1\msvc2015
- cd ..
- ps: Start-FileDownload 'https://github.com/zhang-ray/opus/releases/download/1.0.5/opus-112-win32-build.7z'
- 7z x opus-112-win32-build.7z
- ps: Start-FileDownload 'https://github.com/zhang-ray/portaudio/releases/download/1.0.4/pa19-win32-x86-release-build.7z'
- 7z x pa19-win32-x86-release-build.7z
- mkdir include\boost
#- xcopy C:\Libraries\boost_1_67_0\boost include\boost /E # shorten building time
#- xcopy C:\Libraries\boost_1_67_0\lib32-msvc-14.0 C:\projects\build\Release /E # shorten building time
- mkdir easy-voice-call-build\ && cd easy-voice-call-build\
- cmake -Wno-dev ..\easy-voice-call

Expand All @@ -21,13 +17,12 @@ configuration:
build:
project: ..\easy-voice-call-build\easy-voice-call.sln
parallel: true
#verbosity: quiet
verbosity: quiet

after_build:
- cd client_qt5
- mkdir EasyVoiceCall.win32
- copy Release\client_qt5.exe EasyVoiceCall.win32\EasyVoiceCall.exe
- xcopy C:\Libraries\boost_1_67_0\lib32-msvc-14.0\boost_system-vc140-mt-x32-1_67.dll EasyVoiceCall.win32\
- C:\Qt\5.11.1\msvc2015\bin\windeployqt.exe EasyVoiceCall.win32\EasyVoiceCall.exe
- 7z a ..\..\easy-voice-call\EasyVoiceCall.win32.zip EasyVoiceCall.win32

Expand Down
4 changes: 1 addition & 3 deletions client_essential/Worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ void Worker::syncStart(const std::string &host,const std::string &port,
}
case NetPacket::PayloadType::LoginResponse: {
isLogin = true;
//qDebug() << "&isLogin=" << &isLogin << "\t" << __FUNCTION__;
break;
}
case NetPacket::PayloadType::AudioMessage: {
Expand All @@ -193,7 +192,7 @@ void Worker::syncStart(const std::string &host,const std::string &port,
#ifdef RINGBUFFER
auto bRet = s2cPcmBuffer_.pushElements((uint8_t*)decodedPcm.data(), 1);
if (!bRet){
//qDebug() << "pushElements failed!";

}
#else //RINGBUFFER
device_->write(decodedPcm);
Expand Down Expand Up @@ -235,7 +234,6 @@ void Worker::syncStart(const std::string &host,const std::string &port,
}
}

// qDebug() << "&isLogin=" << &isLogin << "\t" << __FUNCTION__;
if (!isLogin){
toggleState(NetworkState::Disconnected, "Could not Login to Server...");
return;
Expand Down
19 changes: 19 additions & 0 deletions client_qt5/main.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,32 @@
#include "mainwindow.hpp"
#include <QApplication>
#include <QtGlobal>
#include "evc/Logger.hpp"

#ifdef _WIN32
#include "resources/resource.h"
#endif


void initLogger() {
namespace logging = boost::log;
namespace expr = boost::log::expressions;

/// TODO
/// boost::log::keywords::format= "[%TimeStamp%]: %Message%" ;// DOSE NOT WORK!
boost::log::add_file_log(
boost::log::keywords::file_name = "EasyVoiceCall.%Y.%m.%d.%H.%M.%S.log"
);
boost::log::core::get()->set_filter(boost::log::trivial::severity >= boost::log::trivial::trace);
}




int main(int argc, char *argv[]) {
initLogger();


#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
Expand Down
13 changes: 7 additions & 6 deletions client_qt5/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@
#include <QDesktopWidget>
#include <QStyle>
#include <QDir>
#include <QDebug>
#include <memory>
#include <QKeyEvent>
#include <QDesktopServices>
#include "git_info.hpp"


QEvent::Type AudioVolumeEvent::sType = (QEvent::Type)QEvent::registerEventType();
QEvent::Type VadEvent::sType = (QEvent::Type)QEvent::registerEventType();
QEvent::Type NetworkStateEvent::sType = (QEvent::Type)QEvent::registerEventType();
Expand All @@ -32,7 +30,6 @@ MainWindow::MainWindow(QWidget *parent)
{
ui->setupUi(this);


// load setting
try {
QFile file("setting.txt");
Expand Down Expand Up @@ -160,6 +157,11 @@ MainWindow::MainWindow(QWidget *parent)
}
}


for (int i = 0; i < 100000; i++) {
BOOST_LOG_TRIVIAL(error) << "233";
}

}

MainWindow::~MainWindow()
Expand Down Expand Up @@ -317,8 +319,8 @@ void MainWindow::gotoWork(){
);

}
catch (std::exception &e){
qDebug() << "Exception: " << e.what() << "\n";
catch (std::exception &e) {
BOOST_LOG_TRIVIAL(error) << " [" << __FUNCTION__ << "]" << __FILE__ << ":" << __LINE__ << "] " << e.what();
}

}
Expand All @@ -331,7 +333,6 @@ void MainWindow::showMessage(const std::string &message) {
}
else {
ui->statusBar->showMessage(message.c_str());
qDebug() << message.c_str();
}
}
else {
Expand Down
1 change: 1 addition & 0 deletions include/evc/Logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
#include <boost/log/core.hpp>
#include <boost/log/trivial.hpp>
#include <boost/log/expressions.hpp>
#include <boost/log/utility/setup/file.hpp>
1 change: 1 addition & 0 deletions include/evc/Worker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <memory>
#include <thread>
#include <string>
#include "Logger.hpp"
#ifdef RINGBUFFER
#include "evc/RingBuffer.hpp"
#endif // RINGBUFFER
Expand Down

0 comments on commit 2658989

Please sign in to comment.