summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qcore_mac_p.h
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2017-12-08 18:46:44 +0100
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2018-02-12 23:35:13 +0000
commit211791d01cf89bb75691f965d3a4ebc42c5ed8ee (patch)
tree6a85f8b7066144efb9dca3e73942265191aeb9d1 /src/corelib/kernel/qcore_mac_p.h
parentb2b32682a95401f863e2b71a553c1375136e2595 (diff)
Add support for Apple Unified Logging
If the OS supports it, we will now log to the Apple unified logging system in addition to the normal stderr output. These logs can be inspected via the Console application, or the 'log' command line tool. See https://developer.apple.com/documentation/os/logging [ChangeLog][QtCore] Apple Unified Logging is now supported on Apple platforms. Task-number: QTBUG-38156 Done-with: Jake Petroules <jake.petroules@qt.io> Change-Id: I2ab92bd192d5b98aaf77e41501ea7b1ca6ef2425 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/kernel/qcore_mac_p.h')
-rw-r--r--src/corelib/kernel/qcore_mac_p.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/corelib/kernel/qcore_mac_p.h b/src/corelib/kernel/qcore_mac_p.h
index 13143a08bb..9c6cef68b2 100644
--- a/src/corelib/kernel/qcore_mac_p.h
+++ b/src/corelib/kernel/qcore_mac_p.h
@@ -159,6 +159,37 @@ QDebug operator<<(QDebug debug, const QMacAutoReleasePool *pool);
Q_CORE_EXPORT void qt_apple_check_os_version();
+// --------------------------------------------------------------------------
+
+#if !defined(QT_BOOTSTRAPPED) && (QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_12) || !defined(Q_OS_MACOS))
+#define QT_USE_APPLE_UNIFIED_LOGGING
+
+QT_END_NAMESPACE
+#include <os/log.h>
+
+// The compiler isn't smart enough to realize that we're calling these functions
+// guarded by __builtin_available, so we need to also tag each function with the
+// runtime requirements.
+#include <os/availability.h>
+#define OS_LOG_AVAILABILITY API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0))
+QT_BEGIN_NAMESPACE
+
+class Q_CORE_EXPORT AppleUnifiedLogger
+{
+public:
+ static bool messageHandler(QtMsgType msgType, const QMessageLogContext &context, const QString &message,
+ const QString &subsystem = QString()) OS_LOG_AVAILABILITY;
+private:
+ static os_log_type_t logTypeForMessageType(QtMsgType msgType) OS_LOG_AVAILABILITY;
+ static os_log_t cachedLog(const QString &subsystem, const QString &category) OS_LOG_AVAILABILITY;
+};
+
+#undef OS_LOG_AVAILABILITY
+
+#endif
+
+// --------------------------------------------------------------------------
+
QT_END_NAMESPACE
#endif // QCORE_MAC_P_H