Commit 47972811 authored by captainwong's avatar captainwong

QDebug

parent b79c26c6
......@@ -374,9 +374,9 @@ bool simple_libevent_server::start(uint16_t port, std::string& msg)
}
impl->thread = std::thread([this]() {
JLOG_INFO("{} listen thread started", name_.data());
JLOG_INFO("{} listen thread started", name_);
event_base_dispatch(this->impl->base);
JLOG_INFO("{} listen thread exited", name_.data());
JLOG_INFO("{} listen thread exited", name_);
});
started_ = true;
......@@ -393,7 +393,7 @@ void simple_libevent_server::stop()
std::lock_guard<std::mutex> lg(mutex);
if (!impl) { return; }
timeval tv{ 0, 1000 };
const timeval tv{ 0, 1000 };
if (impl->base) {
event_base_loopexit(impl->base, &tv);
......@@ -410,13 +410,17 @@ void simple_libevent_server::stop()
if (impl->workerThreadContexts) {
for (int i = 0; i < threadNum_; i++) {
JLOG_DBUG("simple_libevent_server::stop exiting worker #{}", i);
event_base_loopexit(impl->workerThreadContexts[i]->base, &tv);
JLOG_DBUG("simple_libevent_server::stop exited worker #{}", i);
}
for (int i = 0; i < threadNum_; i++) {
JLOG_DBUG("simple_libevent_server::stop joining worker #{}", i);
impl->workerThreadContexts[i]->thread.join();
event_base_free(impl->workerThreadContexts[i]->base);
delete impl->workerThreadContexts[i];
JLOG_DBUG("simple_libevent_server::stop joined worker #{}", i);
}
delete impl->workerThreadContexts;
......
......@@ -6,14 +6,19 @@
#endif //_WIN32
#define JLIBQT_QDEBUG_FILE_LINE_STREAM "[" << __FUNCTION__ << "ln" << __LINE__ << "]: "
#define JLIBQT_QDEBUG_FILE_LINE_VALUE (QString("[") + __FUNCTION__ + " ln" + QString::number(__LINE__) + "]: ")
#define JLIBQT_QDEBUG_FILE_LINE_STREAM "[" << __FUNCTION__ << __LINE__ << "]: "
#define JLIBQT_QDEBUG_FILE_LINE_VALUE (QString("[") + __FUNCTION__ + " " + QString::number(__LINE__) + "]: ")
#define MYQDEBUG qDebug() << JLIBQT_QDEBUG_FILE_LINE_STREAM
#define MYQINFO qInfo() << JLIBQT_QDEBUG_FILE_LINE_STREAM
#define MYQWARN qWarning() << JLIBQT_QDEBUG_FILE_LINE_STREAM
#define MYQCRITICAL qCritical() << JLIBQT_QDEBUG_FILE_LINE_STREAM
#define MYQDEBUG_NOQUOTE qDebug().noquote() << JLIBQT_QDEBUG_FILE_LINE_STREAM
#define MYQINFO_NOQUOTE qInfo().noquote() << JLIBQT_QDEBUG_FILE_LINE_STREAM
#define MYQWARN_NOQUOTE qWarning().noquote() << JLIBQT_QDEBUG_FILE_LINE_STREAM
#define MYQCRITICAL_NOQUOTE qCritical().noquote() << JLIBQT_QDEBUG_FILE_LINE_STREAM
//! 弹窗报告行号开关
// #define JLIBQT_SHOW_LINE 0
//! 当行号大于下方定义的值时,弹窗报告行号,否则忽略。可在多个cpp文件分别定义不同的值。
......
......@@ -6,7 +6,7 @@
namespace jlib {
namespace win32 {
std::string formatLastError(const std::string& msg)
inline std::string formatLastError(const std::string& msg)
{
// Get system msg
char sysMsg[256];
......@@ -24,7 +24,7 @@ std::string formatLastError(const std::string& msg)
return msg + " failed with error " + std::to_string(eNum) + " (" + sysMsg + ")";
}
std::wstring formatLastError(const std::wstring& msg)
inline std::wstring formatLastError(const std::wstring& msg)
{
// Get system msg
wchar_t sysMsg[256];
......
......@@ -167,16 +167,16 @@ inline JsonValue toJson(const ProcessInfos& pinfos) {
typedef std::function<void(const std::wstring&)> ErrorOutputFunc;
static void dummyErrorOutputFunc(const std::wstring& msg) {
inline void dummyErrorOutputFunc(const std::wstring& msg) {
printf("%ls\n", msg.data());
}
static void outputLastErrorHelper(const std::wstring& msg, ErrorOutputFunc func = nullptr) {
inline void outputLastErrorHelper(const std::wstring& msg, ErrorOutputFunc func = nullptr) {
if (!func) { return; }
func(formatLastError(msg));
}
static std::vector<ProcessInfo::ModuleInfo> getProcessModules(DWORD dwPID, ErrorOutputFunc output = dummyErrorOutputFunc)
inline std::vector<ProcessInfo::ModuleInfo> getProcessModules(DWORD dwPID, ErrorOutputFunc output = dummyErrorOutputFunc)
{
std::vector<ProcessInfo::ModuleInfo> modules = {};
......@@ -217,7 +217,7 @@ static std::vector<ProcessInfo::ModuleInfo> getProcessModules(DWORD dwPID, Error
return(modules);
}
static std::vector<ProcessInfo::ThreadInfo> getProcessThreads(DWORD dwOwnerPID, ErrorOutputFunc output = dummyErrorOutputFunc)
inline std::vector<ProcessInfo::ThreadInfo> getProcessThreads(DWORD dwOwnerPID, ErrorOutputFunc output = dummyErrorOutputFunc)
{
std::vector<ProcessInfo::ThreadInfo> threads = {};
......@@ -326,7 +326,7 @@ static const wchar_t* PROCESS_FILTER[] = {
L"YourPhone.exe",
};
static ProcessInfos getProcessesInfo(ErrorOutputFunc output = dummyErrorOutputFunc, bool withModules = false, bool withThreads = false, const wchar_t** filter = PROCESS_FILTER, size_t filter_count = _countof(PROCESS_FILTER))
inline ProcessInfos getProcessesInfo(ErrorOutputFunc output = dummyErrorOutputFunc, bool withModules = false, bool withThreads = false, const wchar_t** filter = PROCESS_FILTER, size_t filter_count = _countof(PROCESS_FILTER))
{
// pre-process filter
std::unordered_set<std::wstring> filterset;
......
......@@ -155,8 +155,9 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>$(DEVLIBS)\libevent-2.1.12-stable-install\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment