|
|
@@ -15,6 +15,7 @@
|
|
|
#include <string>
|
|
|
|
|
|
#include "logger/format.h"
|
|
|
+#include "common.h"
|
|
|
#include "logger/logger.h"
|
|
|
|
|
|
#if defined( _WIN32 )
|
|
|
@@ -49,7 +50,8 @@ namespace logging {
|
|
|
return fmt_time(round, fmt.c_str());
|
|
|
}
|
|
|
|
|
|
- std::string fmt_time_with_milis(struct timeval round, std::string const & fmt) {
|
|
|
+ std::string fmt_time_with_milis(struct timeval round,
|
|
|
+ std::string const & fmt) {
|
|
|
char buf[64] = {'\0'};
|
|
|
snprintf(buf, sizeof(buf), fmt.c_str(), round.tv_usec);
|
|
|
return fmt_time(round, buf);
|
|
|
@@ -59,8 +61,10 @@ namespace logging {
|
|
|
|
|
|
string_generator parse_date_format_string( char const * str ) {
|
|
|
char const * const end = strchr(str, '}');
|
|
|
- if (end == nullptr)
|
|
|
- throw format_parsing_exception{"expected date-format specifier to terminate"};
|
|
|
+ if (end == nullptr) {
|
|
|
+ std::string error_msg{"expected date-format specifier to terminate"};
|
|
|
+ throw format_parsing_exception{error_msg};
|
|
|
+ }
|
|
|
|
|
|
char const * const has_millis = strstr( str, "%_ms");
|
|
|
std::string fmtstring{str, end};
|
|
|
@@ -119,7 +123,8 @@ namespace logging {
|
|
|
return lp.message;
|
|
|
};
|
|
|
} else {
|
|
|
- throw unknown_format_specifier{std::string("unknown format character: '") + *next + "'"};
|
|
|
+ std::string error_msg{"unknown format character: '"};
|
|
|
+ throw unknown_format_specifier{error_msg + *next + "'"};
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -166,7 +171,8 @@ namespace logging {
|
|
|
while ( ( next = std::strchr( curr, '%' ) + 1 )
|
|
|
!= nullptr ) {
|
|
|
if ( end == next ) {
|
|
|
- throw format_parsing_exception{"expected format specifier, got end of string"}; // TODO
|
|
|
+ std::string error_msg{"expected format specifier, got end of string"};
|
|
|
+ throw format_parsing_exception{error_msg}; // TODO
|
|
|
}
|
|
|
|
|
|
if ( curr < next - 1 ) {
|