diff options
Diffstat (limited to 'include/mbgl')
-rw-r--r-- | include/mbgl/platform/android/log_android.hpp | 24 | ||||
-rw-r--r-- | include/mbgl/platform/darwin/log_nslog.hpp | 18 | ||||
-rw-r--r-- | include/mbgl/platform/default/log_stderr.hpp | 18 | ||||
-rw-r--r-- | include/mbgl/platform/log.hpp | 31 |
4 files changed, 10 insertions, 81 deletions
diff --git a/include/mbgl/platform/android/log_android.hpp b/include/mbgl/platform/android/log_android.hpp deleted file mode 100644 index 94d90a9b36..0000000000 --- a/include/mbgl/platform/android/log_android.hpp +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef MBGL_PLATFORM_ANDROID_LOG_ANDROID -#define MBGL_PLATFORM_ANDROID_LOG_ANDROID - -#include <mbgl/platform/log.hpp> - -namespace mbgl { - -class AndroidLogBackend : public LogBackend { -private: - int severityToPriority(EventSeverity severity); - -public: - inline ~AndroidLogBackend() = default; - - void record(EventSeverity severity, Event event, const std::string &msg); - void record(EventSeverity severity, Event event, const char* format, ...); - void record(EventSeverity severity, Event event, int64_t code); - void record(EventSeverity severity, Event event, int64_t code, const std::string &msg); -}; - - -} - -#endif diff --git a/include/mbgl/platform/darwin/log_nslog.hpp b/include/mbgl/platform/darwin/log_nslog.hpp deleted file mode 100644 index 5b2ed04114..0000000000 --- a/include/mbgl/platform/darwin/log_nslog.hpp +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef MBGL_COMMON_NSLOG_LOG -#define MBGL_COMMON_NSLOG_LOG - -#include <mbgl/platform/log.hpp> - -namespace mbgl { - -class NSLogBackend : public LogBackend { -public: - inline ~NSLogBackend() = default; - - void record(EventSeverity severity, Event event, int64_t code, const std::string &msg); -}; - - -} - -#endif diff --git a/include/mbgl/platform/default/log_stderr.hpp b/include/mbgl/platform/default/log_stderr.hpp deleted file mode 100644 index e07357593d..0000000000 --- a/include/mbgl/platform/default/log_stderr.hpp +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef MBGL_COMMON_STDERR_LOG -#define MBGL_COMMON_STDERR_LOG - -#include <mbgl/platform/log.hpp> - -namespace mbgl { - -class StderrLogBackend : public LogBackend { -public: - inline ~StderrLogBackend() = default; - - void record(EventSeverity severity, Event event, int64_t code, const std::string &msg) override; -}; - - -} - -#endif diff --git a/include/mbgl/platform/log.hpp b/include/mbgl/platform/log.hpp index e5431a07cb..e6b8f17b65 100644 --- a/include/mbgl/platform/log.hpp +++ b/include/mbgl/platform/log.hpp @@ -10,17 +10,6 @@ namespace mbgl { -class LogBackend { -public: - virtual inline ~LogBackend() = default; - - void record(EventSeverity severity, Event event, const std::string &msg); - void record(EventSeverity severity, Event event, const char* format, ...); - void record(EventSeverity severity, Event event, int64_t code); - - virtual void record(EventSeverity severity, Event event, int64_t code, const std::string &msg) = 0; -}; - class Log { private: template <typename T, size_t N> @@ -54,20 +43,20 @@ public: if (!includes(severity, disabledEventSeverities) && !includes(event, disabledEvents) && !includes({ severity, event }, disabledEventPermutations)) { - if (Backend) { - Backend->record(severity, event, ::std::forward<Args>(args)...); - } + record(severity, event, ::std::forward<Args>(args)...); } } - template<typename T, typename ...Args> - static inline const T &Set(Args&& ...args) { - Backend = util::make_unique<T>(::std::forward<Args>(args)...); - return *reinterpret_cast<T *>(Backend.get()); - } - private: - static std::unique_ptr<LogBackend> Backend; + 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, Event event, int64_t code, const std::string &msg); }; } |