summaryrefslogtreecommitdiff
path: root/include/llmr
diff options
context:
space:
mode:
authorMike Morris <michael.patrick.morris@gmail.com>2014-07-11 16:53:18 -0700
committerMike Morris <michael.patrick.morris@gmail.com>2014-07-11 16:53:18 -0700
commit90312783445d67e4857a9b3ec315a9d151dc9760 (patch)
treea4a797f51ab8336ae58206424ef1bc370143db13 /include/llmr
parent5bc77d4243e2d70d4a1a0127fb0e878160601e23 (diff)
parent30298be270226a9bac3eb434e39a7c93eb87503e (diff)
downloadqtlocation-mapboxgl-90312783445d67e4857a9b3ec315a9d151dc9760.tar.gz
Merge branch 'master' into stylesource
Diffstat (limited to 'include/llmr')
-rw-r--r--include/llmr/platform/event.hpp31
-rw-r--r--include/llmr/platform/log.hpp6
-rw-r--r--include/llmr/util/timer.hpp19
3 files changed, 36 insertions, 20 deletions
diff --git a/include/llmr/platform/event.hpp b/include/llmr/platform/event.hpp
index 930f79fac6..c1552b1c6b 100644
--- a/include/llmr/platform/event.hpp
+++ b/include/llmr/platform/event.hpp
@@ -19,7 +19,9 @@ const char *stringifyEventSeverity(EventSeverity eventSeverity);
::std::ostream& operator<<(::std::ostream& os, EventSeverity eventSeverity);
enum class Event : uint8_t {
+ General,
Setup,
+ Shader,
ParseStyle,
ParseTile,
Render,
@@ -30,25 +32,30 @@ Event parseEvent(const char *name);
const char *stringifyEvent(Event event);
::std::ostream& operator<<(::std::ostream& os, Event event);
-constexpr EventSeverity enabledEventSeverities[] = {
-#if DEBUG
+struct EventPermutation {
+ const EventSeverity severity;
+ const Event event;
+
+ constexpr bool operator==(const EventPermutation &rhs) const {
+ return severity == rhs.severity && event == rhs.event;
+ }
+};
+
+constexpr EventSeverity disabledEventSeverities[] = {
+#if !DEBUG
EventSeverity::Debug,
#endif
-
-#if TESTING
+#if !TESTING
EventSeverity::Test,
#endif
+};
+
- EventSeverity::Info,
- EventSeverity::Warning,
- EventSeverity::Error,
+constexpr Event disabledEvents[] = {
};
-/* enabled event classes */
-constexpr Event enabledEvents[] = {
- Event::ParseStyle,
- Event::ParseTile,
- Event::HttpRequest,
+constexpr EventPermutation disabledEventPermutations[] = {
+ { EventSeverity::Debug, Event::Shader }
};
}
diff --git a/include/llmr/platform/log.hpp b/include/llmr/platform/log.hpp
index 48c88a1fdc..7b39370046 100644
--- a/include/llmr/platform/log.hpp
+++ b/include/llmr/platform/log.hpp
@@ -12,6 +12,7 @@ class LogBackend {
public:
virtual inline ~LogBackend() = default;
virtual void record(EventSeverity severity, Event event, const std::string &msg) = 0;
+ virtual void record(EventSeverity severity, Event event, const char* format, ...) = 0;
virtual void record(EventSeverity severity, Event event, int64_t code) = 0;
virtual void record(EventSeverity severity, Event event, int64_t code, const std::string &msg) = 0;
};
@@ -46,8 +47,9 @@ public:
template <typename ...Args>
static inline void Record(EventSeverity severity, Event event, Args&& ...args) {
- if (includes(severity, enabledEventSeverities) &&
- includes(event, enabledEvents)) {
+ if (!includes(severity, disabledEventSeverities) &&
+ !includes(event, disabledEvents) &&
+ !includes({ severity, event }, disabledEventPermutations)) {
if (Backend) {
Backend->record(severity, event, ::std::forward<Args>(args)...);
}
diff --git a/include/llmr/util/timer.hpp b/include/llmr/util/timer.hpp
index a1e8e05a9d..5dc0cfaf3f 100644
--- a/include/llmr/util/timer.hpp
+++ b/include/llmr/util/timer.hpp
@@ -1,6 +1,8 @@
#ifndef LLMR_UTIL_TIMER
#define LLMR_UTIL_TIMER
+#include <llmr/platform/event.hpp>
+
#include <string>
namespace llmr {
@@ -9,24 +11,29 @@ namespace util {
#ifndef DISABLE_TIMER
class timer {
public:
- timer();
- timer(const std::string &name);
+ timer(Event event = Event::General);
+ timer(EventSeverity severity, Event event = Event::General);
+ timer(const std::string &name, Event event = Event::General);
+ timer(const std::string &name, EventSeverity severity, Event event = Event::General);
void report(const std::string &name);
~timer();
private:
const std::string name;
+ EventSeverity severity = EventSeverity::Debug;
+ Event event = Event::General;
uint64_t start;
};
#else
class timer {
- inline timer() {}
- inline timer(const std::string &name) {}
- inline void report (const std::string &name) {}
+ inline timer(Event event = Event::General);
+ inline timer(EventSeverity severity, Event event = Event::General);
+ inline timer(const std::string &name, Event event = Event::General);
+ inline timer(const std::string &name, EventSeverity severity, Event event = Event::General);
+ inline void report(const std::string &name) {}
inline ~timer() {}
};
#endif
-
}
}