Got logging and errors basically all working the way I want
This commit is contained in:
@@ -10,11 +10,21 @@ nb::DefaultDebugLogger logger(std::cout);
|
||||
#endif // _NB_NO_LOGGER
|
||||
|
||||
bool nb::DefaultDebugLogger::process(const LogEvent& msg) {
|
||||
constexpr size_t level_field_width = 3;
|
||||
constexpr size_t msg_prompt_length = level_field_width+6;
|
||||
for (const auto os : this->_ostream) {
|
||||
*os << "[";
|
||||
os->width(level_field_width);
|
||||
(*os << std::to_string(msg.lvl)).width(level_field_width);
|
||||
*os << "] :: ";
|
||||
std::string fileloc="";
|
||||
if (!msg.file.empty()) {
|
||||
fileloc += "(" + msg.file + ":" + std::to_string(msg.line) + ") - ";
|
||||
}
|
||||
*os << indent_strblock(
|
||||
msg.msg,
|
||||
std::string(10, ' '),
|
||||
"[ "+std::to_string(msg.lvl)+" ] : "
|
||||
fileloc + msg.msg,
|
||||
std::string(15 - msg_prompt_length, ' '),
|
||||
""
|
||||
) << nb::NEWLINE;
|
||||
}
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user