Files
MapLibreParticleLab/platform/android/log_android.cpp
Thiago Marcos P. Santos 51bc265db3 Make the logging system static
No initialization is needed anymore and we can use the logging functions
safely at any point of the code (threading is not handled though, so you
might get multiplexed messages if you log from two threads
simultaneously).
2015-03-12 13:28:41 +02:00

38 lines
859 B
C++

#include <mbgl/platform/log.hpp>
#define __STDC_FORMAT_MACROS // NDK bug workaround: https://code.google.com/p/android/issues/detail?id=72349
#include <cinttypes>
#include <android/log.h>
namespace mbgl {
namespace {
int severityToPriority(EventSeverity severity) {
switch(severity) {
case EventSeverity::Debug:
return ANDROID_LOG_DEBUG;
case EventSeverity::Info:
return ANDROID_LOG_INFO;
case EventSeverity::Warning:
return ANDROID_LOG_WARN;
case EventSeverity::Error:
return ANDROID_LOG_ERROR;
default:
return ANDROID_LOG_VERBOSE;
}
}
} // namespace
void Log::platformRecord(EventSeverity severity, Event event, int64_t code, const std::string &msg) {
__android_log_print(severityToPriority(severity), EventClass(event).c_str(), "(%" PRId64 ") %s", code, msg.c_str());
}
}