diff options
Diffstat (limited to 'contrib/epee/src')
-rw-r--r-- | contrib/epee/src/CMakeLists.txt | 4 | ||||
-rw-r--r-- | contrib/epee/src/mlog.cpp | 52 |
2 files changed, 53 insertions, 3 deletions
diff --git a/contrib/epee/src/CMakeLists.txt b/contrib/epee/src/CMakeLists.txt index c512e3b86..5c92e32bd 100644 --- a/contrib/epee/src/CMakeLists.txt +++ b/contrib/epee/src/CMakeLists.txt @@ -29,7 +29,7 @@ add_library(epee STATIC byte_slice.cpp hex.cpp http_auth.cpp mlog.cpp net_helper.cpp net_utils_base.cpp string_tools.cpp wipeable_string.cpp levin_base.cpp memwipe.c connection_basic.cpp network_throttle.cpp network_throttle-detail.cpp mlocker.cpp buffer.cpp net_ssl.cpp) -if (USE_READLINE AND GNU_READLINE_FOUND) +if (USE_READLINE AND (GNU_READLINE_FOUND OR DEPENDS AND NOT MINGW)) add_library(epee_readline STATIC readline_buffer.cpp) endif() @@ -62,7 +62,7 @@ target_link_libraries(epee ${OPENSSL_LIBRARIES} ${EXTRA_LIBRARIES}) -if (USE_READLINE AND GNU_READLINE_FOUND) +if (USE_READLINE AND (GNU_READLINE_FOUND OR DEPENDS AND NOT MINGW)) target_link_libraries(epee_readline PUBLIC easylogging diff --git a/contrib/epee/src/mlog.cpp b/contrib/epee/src/mlog.cpp index 4c6ad5516..66dfabcdf 100644 --- a/contrib/epee/src/mlog.cpp +++ b/contrib/epee/src/mlog.cpp @@ -109,7 +109,7 @@ static const char *get_default_categories(int level) categories = "*:DEBUG"; break; case 3: - categories = "*:TRACE"; + categories = "*:TRACE,*.dump:DEBUG"; break; case 4: categories = "*:TRACE"; @@ -472,4 +472,54 @@ void reset_console_color() { } +static bool mlog(el::Level level, const char *category, const char *format, va_list ap) noexcept +{ + int size = 0; + char *p = NULL; + va_list apc; + bool ret = true; + + /* Determine required size */ + va_copy(apc, ap); + size = vsnprintf(p, size, format, apc); + va_end(apc); + if (size < 0) + return false; + + size++; /* For '\0' */ + p = (char*)malloc(size); + if (p == NULL) + return false; + + size = vsnprintf(p, size, format, ap); + if (size < 0) + { + free(p); + return false; + } + + try + { + MCLOG(level, category, el::Color::Default, p); + } + catch(...) + { + ret = false; + } + free(p); + + return ret; +} + +#define DEFLOG(fun,lev) \ + bool m##fun(const char *category, const char *fmt, ...) { va_list ap; va_start(ap, fmt); bool ret = mlog(el::Level::lev, category, fmt, ap); va_end(ap); return ret; } + +DEFLOG(error, Error) +DEFLOG(warning, Warning) +DEFLOG(info, Info) +DEFLOG(debug, Debug) +DEFLOG(trace, Trace) + +#undef DEFLOG + #endif //_MLOG_H_ |