26 DLogger* DLogger::m_pInstance = NULL;
45 void DLogger::init(
string file)
49 m_pInstance =
new DLogger(file);
53 void DLogger::init(
string level,
string mode,
string file)
57 m_pInstance =
new DLogger(level,mode,file);
66 datFormat.setFormatspec(
"dd/mm/yyyy hh:mi:ss");
69 DLogger::DLogger(
string file)
72 propMap props = pf.getProperties(file);
77 datFormat.setFormatspec(
"dd/mm/yyyy hh:mi:ss");
80 level = props[
"LEVEL"];
82 filepath = props[
"FILEPATH"];
84 out.open(filepath.c_str(),ios::app | ios::binary);
85 datFormat.setFormatspec(props[
"DATEFMT"]);
87 DLogger::DLogger(
string level,
string mode,
string filepath)
91 this->filepath = filepath;
99 void DLogger::write(
string msg,
string mod)
102 string te = this->datFormat.format(dat);
105 msg =
"[" + te +
"] <"+mod+
"> :"+msg+
"\n";
106 m_pInstance->p_mutex.lock();
107 m_pInstance->out.write(msg.c_str(),msg.length());
108 m_pInstance->out << flush;
109 m_pInstance->p_mutex.unlock();
113 msg =
"[" + te +
"] <"+mod+
"> :"+msg+
"\n";
114 m_pInstance->p_mutex.lock();
115 cout << msg << flush;
116 m_pInstance->p_mutex.unlock();
120 void DLogger::info(
string msg)
122 m_pInstance->write(msg,
"info");
125 void DLogger::debug(
string msg)
127 m_pInstance->write(msg,
"debug");
130 void DLogger::error(
string msg)
132 m_pInstance->write(msg,
"error");