#include "logger.h" #include "utils.h" namespace graft_cv{ CGcvLogger::CGcvLogger(ofstream& ofs) :m_target(terminal) ,m_level(debug) ,m_outfile(ofs) ,m_pMtx(new std::mutex()) { cout<lock(); string prefix; if(act_level == debug){ prefix = " [DEBUG] "; } else if(act_level== info){ prefix =" [INFO] "; } else if(act_level == warning){ prefix = " [WARNING] "; } else if(act_level == error){ prefix= " [ERROR] "; } else { prefix =""; } string output_content= currTime() + prefix + text +"\n"; if(this->m_level <= act_level && this->m_target!= file){ cout <m_target != terminal){ m_outfile<< output_content; m_outfile.flush(); } m_pMtx->unlock(); } void CGcvLogger::DEBUG(string text) { if(debug>=m_level){ this->output(text,debug); } } void CGcvLogger::INFO(string text) { if(info>=m_level){ this->output(text,info); } } void CGcvLogger::WARNING(string text) { if(warning>=m_level){ this->output(text,warning); } } void CGcvLogger::ERRORINFO(string text) { if(error>=m_level){ this->output(text,error); } } };