33enum LogLevel_t { LOG, DEBUG, INFO, WARNING, ERROR, CRITICAL };
36class Logger :
public rapidjson::Document {
39 std::ofstream _logFile;
43 : rapidjson::Document(rapidjson::Type::kObjectType), _level(level) {
44 _logFile.open(filename, std::ofstream::out);
51 void setLevel(
LogLevel_t level) { _level = level; }
52 virtual void serialize(
Writer &)
const = 0;
54 rapidjson::StringBuffer sb;
56 serialize(writerAdapter);
57 _logFile << sb.GetString();
61 static const std::string buildDate(
void) {
62 const time_t now = time(NULL);
64 if (localtime_r(&now, &tmp) == NULL) {
65 throw std::runtime_error(
"Error calling localtime_r: " + std::string(strerror(errno)));
69 strftime(bdate, 1024,
"%c", &tmp);