diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2016-11-22 15:43:19 +0100 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2016-11-22 20:58:51 +0100 |
commit | e76de0540284118845c93c4351c82c6c8d5a090a (patch) | |
tree | dc295f87b74c5a4766444f6d1e7020e6219017a8 /include/mbgl/platform | |
parent | 117863f1114551407c481abc752f5fcfd139c878 (diff) | |
download | qtlocation-mapboxgl-e76de0540284118845c93c4351c82c6c8d5a090a.tar.gz |
[build] move logging to util
Diffstat (limited to 'include/mbgl/platform')
-rw-r--r-- | include/mbgl/platform/event.hpp | 58 | ||||
-rw-r--r-- | include/mbgl/platform/log.hpp | 80 | ||||
-rw-r--r-- | include/mbgl/platform/platform.hpp | 32 |
3 files changed, 0 insertions, 170 deletions
diff --git a/include/mbgl/platform/event.hpp b/include/mbgl/platform/event.hpp deleted file mode 100644 index 7ad3d914e8..0000000000 --- a/include/mbgl/platform/event.hpp +++ /dev/null @@ -1,58 +0,0 @@ -#pragma once - -#include <cstdint> - -namespace mbgl { - -enum class EventSeverity : uint8_t { - Debug, - Info, - Warning, - Error, -}; - -enum class Event : uint8_t { - General, - Setup, - Shader, - ParseStyle, - ParseTile, - Render, - Style, - Database, - HttpRequest, - Sprite, - Image, - OpenGL, - JNI, - Android, - Crash, - Glyph, -}; - -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[] = { -#ifdef NDEBUG - EventSeverity(-1) // Avoid zero size array -#else - EventSeverity::Debug -#endif -}; - -constexpr Event disabledEvents[] = { - Event(-1) // Avoid zero size array -}; - -constexpr EventPermutation disabledEventPermutations[] = { - { EventSeverity::Debug, Event::Shader } -}; - -} // namespace mbgl diff --git a/include/mbgl/platform/log.hpp b/include/mbgl/platform/log.hpp deleted file mode 100644 index d5bb1c2fcc..0000000000 --- a/include/mbgl/platform/log.hpp +++ /dev/null @@ -1,80 +0,0 @@ -#pragma once - -#include <mbgl/platform/event.hpp> - -#include <mbgl/util/noncopyable.hpp> - -#include <memory> -#include <string> - -namespace mbgl { - -class Log { -public: - class Observer : private util::noncopyable { - public: - virtual ~Observer() = default; - - // When an observer is set, this function will be called for every log - // message. Returning true will consume the message. - virtual bool onRecord(EventSeverity severity, Event event, int64_t code, const std::string &msg) = 0; - }; - - class NullObserver : public Observer { - bool onRecord(EventSeverity, Event, int64_t, const std::string&) override { - return true; - } - }; - - static void setObserver(std::unique_ptr<Observer> Observer); - static std::unique_ptr<Observer> removeObserver(); - -private: - template <typename T, size_t N> - constexpr static bool includes(const T e, const T (&l)[N], const size_t i = 0) { - return i < N && (l[i] == e || includes(e, l, i + 1)); - } - -public: - template <typename ...Args> - static void Debug(Event event, Args&& ...args) { - Record(EventSeverity::Debug, event, ::std::forward<Args>(args)...); - } - - template <typename ...Args> - static void Info(Event event, Args&& ...args) { - Record(EventSeverity::Info, event, ::std::forward<Args>(args)...); - } - - template <typename ...Args> - static void Warning(Event event, Args&& ...args) { - Record(EventSeverity::Warning, event, ::std::forward<Args>(args)...); - } - - template <typename ...Args> - static void Error(Event event, Args&& ...args) { - Record(EventSeverity::Error, event, ::std::forward<Args>(args)...); - } - - template <typename ...Args> - static void Record(EventSeverity severity, Event event, Args&& ...args) { - if (!includes(severity, disabledEventSeverities) && - !includes(event, disabledEvents) && - !includes({ severity, event }, disabledEventPermutations)) { - record(severity, event, ::std::forward<Args>(args)...); - } - } - -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, int64_t code, const std::string &msg); - - // This method is the data sink that must be implemented by each platform we - // support. It should ideally output the error message in a human readable - // format to the developer. - static void platformRecord(EventSeverity severity, const std::string &msg); -}; - -} // namespace mbgl diff --git a/include/mbgl/platform/platform.hpp b/include/mbgl/platform/platform.hpp deleted file mode 100644 index cc8327c470..0000000000 --- a/include/mbgl/platform/platform.hpp +++ /dev/null @@ -1,32 +0,0 @@ -#pragma once - -#include <memory> -#include <string> - -namespace mbgl { -namespace platform { - -class Request; - -// Uppercase a string, potentially using platform-specific routines. -std::string uppercase(const std::string &string); - -// Lowercase a string, potentially using platform-specific routines. -std::string lowercase(const std::string &string); - -// Gets the name of the current thread. -std::string getCurrentThreadName(); - -// Set the name of the current thread, truncated at 15. -void setCurrentThreadName(const std::string& name); - -// Makes the current thread low priority. -void makeThreadLowPriority(); - -// Shows an alpha image with the specified dimensions in a named window. -void showDebugImage(std::string name, const char *data, size_t width, size_t height); - -// Shows an alpha image with the specified dimensions in a named window. -void showColorDebugImage(std::string name, const char *data, size_t logical_width, size_t logical_height, size_t width, size_t height); -} // namespace platform -} // namespace mbgl |