diff --git a/general/inc/loger.h b/general/inc/loger.h index 73032f7..e5350ba 100644 --- a/general/inc/loger.h +++ b/general/inc/loger.h @@ -28,7 +28,7 @@ public: Loger(string path,string prefix); Loger(string path,string prefix,bool old); ~Loger(); - #define DEBUG_FILE_POSITION __FILE__,__LINE__ + #define FILE_POSITION __FILE__,__LINE__ void SetMinimalLevel(Level); void SetWorkMode(Mode); int Debug(string,string file = __FILE__,int line = __LINE__); diff --git a/general/src/function/async.hpp b/general/src/function/async.hpp new file mode 100644 index 0000000..dc2d299 --- /dev/null +++ b/general/src/function/async.hpp @@ -0,0 +1,39 @@ +#pragma once +// 一个异步线程的封装 +template +class ASyncProcess { + public: + ASyncProcess(Function t,Ret &ret,Args... args){ + std::cout<<"ASyncProcess construct"<m_finish = true; + } + catch(const std::exception& e) + { + std::cerr << e.what() << '\n'; + } + }); + } + ASyncProcess(Function t,Ret &ret){ + std::cout<<"ASyncProcess construct"<m_finish = true; + mMutex.unlock(); + }); + } + bool Finish(){ + return m_finish; + } + virtual ~ASyncProcess() { + mThread->detach(); + } + private: + bool m_finish = false; + std::thread *mThread; + std::mutex mMutex; +}; diff --git a/general/src/loger.cpp b/general/src/loger.cpp index 311c165..4565893 100644 --- a/general/src/loger.cpp +++ b/general/src/loger.cpp @@ -39,7 +39,7 @@ int Loger::Debug(string dat,string function,int line) { } // 还没有过天 if(getTimeDate() == this->mCurrentDate){ - string tmp = "[" + this->mPrefix + "] "; + string tmp = "[DEBUG] "; tmp += getTime(); tmp += ": "; tmp += dat; @@ -57,7 +57,7 @@ int Loger::Debug(string dat,string function,int line) { std::cout<<"error Loger open file\r\n"<mPrefix + "] "; + string tmp = "[DEBUG] "; tmp += getTime(); tmp += ": "; tmp += dat; @@ -133,7 +133,7 @@ int Loger::Warning(string dat,string function,int line) { } // 还没有过天 if(getTimeDate() == this->mCurrentDate){ - string tmp = "[" + this->mPrefix + "] "; + string tmp = "[WARNING] "; tmp += getTime(); tmp += ": "; tmp += dat; @@ -151,7 +151,7 @@ int Loger::Warning(string dat,string function,int line) { std::cout<<"error Loger open file\r\n"<mPrefix + "] "; + string tmp = "[WARNING] "; tmp += getTime(); tmp += ": "; tmp += dat; @@ -164,7 +164,6 @@ int Loger::Warning(string dat,string function,int line) { return 0; } - int Loger::Info(string dat,string function,int line) { if(mLevel > LEVEL_WARNING){ return 0; @@ -182,7 +181,7 @@ int Loger::Info(string dat,string function,int line) { } // 还没有过天 if(getTimeDate() == this->mCurrentDate){ - string tmp = "[" + this->mPrefix + "] "; + string tmp = "[INFO] "; tmp += getTime(); tmp += ": "; tmp += dat; @@ -200,7 +199,7 @@ int Loger::Info(string dat,string function,int line) { std::cout<<"error Loger open file\r\n"<mPrefix + "] "; + string tmp = "[INFO] "; tmp += getTime(); tmp += ": "; tmp += dat;