[core] allow logging error codes and formatting strings at the same time
This commit is contained in:
@@ -67,8 +67,8 @@ public:
|
||||
|
||||
private:
|
||||
static void record(EventSeverity severity, Event event, const std::string &msg);
|
||||
static void record(EventSeverity severity, Event event, const char* format, ...);
|
||||
static void record(EventSeverity severity, Event event, int64_t code);
|
||||
static void record(EventSeverity severity, Event event, const char* format = "", ...);
|
||||
static void record(EventSeverity severity, Event event, int64_t code, const char* format = "", ...);
|
||||
static void record(EventSeverity severity, Event event, int64_t code, const std::string &msg);
|
||||
|
||||
// This method is the data sink that must be implemented by each platform we
|
||||
|
||||
@@ -38,8 +38,14 @@ void Log::record(EventSeverity severity, Event event, const char* format, ...) {
|
||||
record(severity, event, -1, msg);
|
||||
}
|
||||
|
||||
void Log::record(EventSeverity severity, Event event, int64_t code) {
|
||||
record(severity, event, code, std::string());
|
||||
void Log::record(EventSeverity severity, Event event, int64_t code, const char* format, ...) {
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
char msg[4096];
|
||||
vsnprintf(msg, sizeof(msg), format, args);
|
||||
va_end(args);
|
||||
|
||||
record(severity, event, code, std::string{ msg });
|
||||
}
|
||||
|
||||
void Log::record(EventSeverity severity, Event event, int64_t code, const std::string &msg) {
|
||||
|
||||
Reference in New Issue
Block a user