summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <tmpsantos@gmail.com>2015-03-09 16:15:18 +0200
committerThiago Marcos P. Santos <thiago@mapbox.com>2015-03-12 13:28:41 +0200
commit51bc265db341f1d98b4fd46be80241771f854eb5 (patch)
treedc77abcdc9b423b59da94d32ae2afb0f57fb6f8d /platform
parent2948e7d121343359b817d2fb0eb383e257ab84c8 (diff)
downloadqtlocation-mapboxgl-51bc265db341f1d98b4fd46be80241771f854eb5.tar.gz
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).
Diffstat (limited to 'platform')
-rw-r--r--platform/android/log_android.cpp10
-rw-r--r--platform/darwin/log_nslog.mm6
-rw-r--r--platform/default/log_stderr.cpp4
-rw-r--r--platform/ios/MGLMapView.mm6
4 files changed, 13 insertions, 13 deletions
diff --git a/platform/android/log_android.cpp b/platform/android/log_android.cpp
index e1bec3e0cb..9de8232bac 100644
--- a/platform/android/log_android.cpp
+++ b/platform/android/log_android.cpp
@@ -1,4 +1,4 @@
-#include <mbgl/platform/android/log_android.hpp>
+#include <mbgl/platform/log.hpp>
#define __STDC_FORMAT_MACROS // NDK bug workaround: https://code.google.com/p/android/issues/detail?id=72349
#include <cinttypes>
@@ -7,7 +7,9 @@
namespace mbgl {
-int AndroidLogBackend::severityToPriority(EventSeverity severity) {
+namespace {
+
+int severityToPriority(EventSeverity severity) {
switch(severity) {
case EventSeverity::Debug:
return ANDROID_LOG_DEBUG;
@@ -26,7 +28,9 @@ int AndroidLogBackend::severityToPriority(EventSeverity severity) {
}
}
-void AndroidLogBackend::record(EventSeverity severity, Event event, int64_t code, const std::string &msg) {
+} // 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());
}
diff --git a/platform/darwin/log_nslog.mm b/platform/darwin/log_nslog.mm
index edcf41ebb2..5d53ed812f 100644
--- a/platform/darwin/log_nslog.mm
+++ b/platform/darwin/log_nslog.mm
@@ -1,11 +1,11 @@
-#include <mbgl/platform/darwin/log_nslog.hpp>
+#include <mbgl/platform/log.hpp>
#import <Foundation/Foundation.h>
namespace mbgl {
-void NSLogBackend::record(EventSeverity severity, Event event, int64_t code,
- const std::string &msg) {
+void Log::platformRecord(EventSeverity severity, Event event, int64_t code,
+ const std::string &msg) {
NSString *message =
[[NSString alloc] initWithBytes:msg.data() length:msg.size() encoding:NSUTF8StringEncoding];
NSLog(@"[%s] %s: (%lld) %@", EventSeverityClass(severity).c_str(), EventClass(event).c_str(),
diff --git a/platform/default/log_stderr.cpp b/platform/default/log_stderr.cpp
index 891bfd57f8..3305176d96 100644
--- a/platform/default/log_stderr.cpp
+++ b/platform/default/log_stderr.cpp
@@ -1,10 +1,10 @@
-#include <mbgl/platform/default/log_stderr.hpp>
+#include <mbgl/platform/log.hpp>
#include <iostream>
namespace mbgl {
-void StderrLogBackend::record(EventSeverity severity, Event event, int64_t code, const std::string &msg) {
+void Log::platformRecord(EventSeverity severity, Event event, int64_t code, const std::string &msg) {
std::cerr << "[" << severity << "] " << event << ": (" << code << ") " << msg << std::endl;
}
diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm
index 1ab1afcbba..f60d3a05ff 100644
--- a/platform/ios/MGLMapView.mm
+++ b/platform/ios/MGLMapView.mm
@@ -1,6 +1,6 @@
#import "MGLMapView.h"
-#import <mbgl/platform/darwin/log_nslog.hpp>
+#import <mbgl/platform/log.hpp>
#import <mbgl/platform/gl.hpp>
#import <GLKit/GLKit.h>
@@ -181,10 +181,6 @@ mbgl::DefaultFileSource *mbglFileSource = nullptr;
- (BOOL)commonInit
{
- // set logging backend
- //
- mbgl::Log::Set<mbgl::NSLogBackend>();
-
// create context
//
_context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];