aboutsummaryrefslogtreecommitdiff
path: root/contrib/epee/src/mlog.cpp
diff options
context:
space:
mode:
authorluigi1111 <luigi1111w@gmail.com>2019-09-24 10:05:21 -0500
committerluigi1111 <luigi1111w@gmail.com>2019-09-24 10:05:21 -0500
commit8c41d36a083da4ffb4ec406e56c888d0105abc08 (patch)
tree0c43572414addbdef286799b297f4648c60d407d /contrib/epee/src/mlog.cpp
parentMerge pull request #5848 (diff)
parentProperly format multiline logs (diff)
downloadmonero-8c41d36a083da4ffb4ec406e56c888d0105abc08.tar.xz
Merge pull request #5864
32f725d Properly format multiline logs (moneromooo-monero)
Diffstat (limited to 'contrib/epee/src/mlog.cpp')
-rw-r--r--contrib/epee/src/mlog.cpp38
1 files changed, 37 insertions, 1 deletions
diff --git a/contrib/epee/src/mlog.cpp b/contrib/epee/src/mlog.cpp
index 4c6ad5516..0cf579840 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,40 @@ void reset_console_color() {
}
+static void mlog(el::Level level, const char *category, const char *format, va_list ap)
+{
+ int size = 0;
+ char *p = NULL;
+ va_list apc;
+
+ /* Determine required size */
+ va_copy(apc, ap);
+ size = vsnprintf(p, size, format, apc);
+ va_end(apc);
+ if (size < 0)
+ return;
+
+ size++; /* For '\0' */
+ p = (char*)malloc(size);
+ if (p == NULL)
+ return;
+
+ size = vsnprintf(p, size, format, ap);
+ if (size < 0)
+ {
+ free(p);
+ return;
+ }
+
+ MCLOG(level, category, el::Color::Default, p);
+ free(p);
+}
+
+void mfatal(const char *category, const char *fmt, ...) { va_list ap; va_start(ap, fmt); mlog(el::Level::Fatal, category, fmt, ap); va_end(ap); }
+void merror(const char *category, const char *fmt, ...) { va_list ap; va_start(ap, fmt); mlog(el::Level::Error, category, fmt, ap); va_end(ap); }
+void mwarning(const char *category, const char *fmt, ...) { va_list ap; va_start(ap, fmt); mlog(el::Level::Warning, category, fmt, ap); va_end(ap); }
+void minfo(const char *category, const char *fmt, ...) { va_list ap; va_start(ap, fmt); mlog(el::Level::Info, category, fmt, ap); va_end(ap); }
+void mdebug(const char *category, const char *fmt, ...) { va_list ap; va_start(ap, fmt); mlog(el::Level::Debug, category, fmt, ap); va_end(ap); }
+void mtrace(const char *category, const char *fmt, ...) { va_list ap; va_start(ap, fmt); mlog(el::Level::Trace, category, fmt, ap); va_end(ap); }
+
#endif //_MLOG_H_