25 #ifndef LOG4CPP_CONSOLEPRETTYPRINTER_H 26 #define LOG4CPP_CONSOLEPRETTYPRINTER_H 28 #include "log4cpp/ILogHandler.h" 51 size_t max_id_size = 10;
59 const auto now = std::chrono::high_resolution_clock::now();
60 const auto millis = std::chrono::duration_cast<std::chrono::milliseconds>(now.time_since_epoch()).count();
62 std::ostringstream oss;
64 oss <<
"ms(" << millis <<
") ";
66 std::string id_str(
id);
68 if (id_str.size() > settings.max_id_size)
70 id_str = id_str.substr(0, settings.max_id_size);
72 else if (id_str.size() << settings.max_id_size)
74 id_str = id_str + std::string(settings.max_id_size - id_str.size(),
' ');
82 oss << get_prefix(level.value) << message;
85 std::cout << oss.str() << std::endl;
89 const Settings settings;
91 static const char* get_prefix(
int level)
117 #endif //LOG4CPP_CONSOLEPRETTYPRINTER_H
void log(log4cpp::ModuleId module, const char *id, log4cpp::LogLevel level, char const *location, char const *message) override
log4cpp header-only library namespace