|
|
@ -1,8 +1,9 @@ |
|
|
|
#include "../lib/log.hpp" |
|
|
|
#include "../lib/log.hpp" |
|
|
|
|
|
|
|
|
|
|
|
log::log(string _dir, bool _isKeepOpen) { |
|
|
|
log::log(string _dir, bool _isKeepOpen, bool _printInConsole = false) { |
|
|
|
dir = _dir; |
|
|
|
dir = _dir; |
|
|
|
isKeepOpen = _isKeepOpen; |
|
|
|
isKeepOpen = _isKeepOpen; |
|
|
|
|
|
|
|
printInConsole = _printInConsole; |
|
|
|
|
|
|
|
|
|
|
|
if (!isdir()) { |
|
|
|
if (!isdir()) { |
|
|
|
cout << "Eror log dir path invalid!" << endl; |
|
|
|
cout << "Eror log dir path invalid!" << endl; |
|
|
@ -44,6 +45,10 @@ void log::setMoment() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void log::put(string logline) { |
|
|
|
void log::put(string logline) { |
|
|
|
|
|
|
|
if (printInConsole) { |
|
|
|
|
|
|
|
cout << logline << endl; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
setMoment(); |
|
|
|
setMoment(); |
|
|
|
setPrefix(logline); |
|
|
|
setPrefix(logline); |
|
|
|
|
|
|
|
|
|
|
@ -68,10 +73,8 @@ void log::put(string logline) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
cout << logline << endl; |
|
|
|
|
|
|
|
logfile << logline << endl; |
|
|
|
logfile << logline << endl; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!isKeepOpen && logfile.is_open()) { |
|
|
|
if (!isKeepOpen && logfile.is_open()) { |
|
|
|
loose(); |
|
|
|
loose(); |
|
|
|
} |
|
|
|
} |
|
|
|