summaryrefslogtreecommitdiff
path: root/src/mbgl/platform
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <thiago@mapbox.com>2015-03-15 03:20:53 +0200
committerKonstantin Käfer <mail@kkaefer.com>2015-03-18 12:51:33 +0100
commit3254cdc85c4a836cb57b2b56770e5a1ec26adc23 (patch)
tree4898d19879ecf1825309cd7f9c43faa24b14f97b /src/mbgl/platform
parent66841bf7eb0d85b5f7c38092e17b9cc16a1dc18a (diff)
downloadqtlocation-mapboxgl-3254cdc85c4a836cb57b2b56770e5a1ec26adc23.tar.gz
Log the Environment ID and the Thread name
To make it easier to debug, add the Environment ID and the Thread name to the log messages. For instance log messages from the TileParser will look like: [WARNING] {0}{TileWorker_15/18653/9486}[ParseTile]: some relevant warning message | | | | | | | +-> Component | | +--------------------> Thread name | +----------------------------------> Environment ID +------------------------------------------> Severity level Log messages that are not inside an Environment::Scope will work normally and will look like: [WARNING] [JNI]: some relevant warning message Fixes #882.
Diffstat (limited to 'src/mbgl/platform')
-rw-r--r--src/mbgl/platform/log.cpp26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/mbgl/platform/log.cpp b/src/mbgl/platform/log.cpp
index e9712f727c..d6cbc4fd11 100644
--- a/src/mbgl/platform/log.cpp
+++ b/src/mbgl/platform/log.cpp
@@ -1,6 +1,9 @@
#include <mbgl/platform/log.hpp>
+#include <mbgl/map/environment.hpp>
+
#include <cstdarg>
+#include <sstream>
namespace mbgl {
@@ -37,7 +40,28 @@ void Log::record(EventSeverity severity, Event event, int64_t code, const std::s
return;
}
- platformRecord(severity, event, code, msg);
+ std::stringstream logStream;
+
+ if (Environment::inScope()) {
+ logStream << "{" << Environment::Get().getID() << "}";
+ }
+
+ const std::string threadName = Environment::threadName();
+ if (!threadName.empty()) {
+ logStream << "{" << threadName << "}";
+ }
+
+ logStream << "[" << event << "]";
+
+ if (code >= 0) {
+ logStream << "(" << code << ")";
+ }
+
+ if (!msg.empty()) {
+ logStream << ": " << msg;
+ }
+
+ platformRecord(severity, logStream.str());
}
}