Commit 1031d2c6 by Kenneth Russell Committed by Commit Bot

Upstream Mac logging changes from WebKit.

Use os_log_with_type in ANGLE's logging facility rather than fprintf. Bug: angleproject:4263 Change-Id: I0c418fc5544001bf4f47ff511d05de2f0ebaa1de Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1987145Reviewed-by: 's avatarKai Ninomiya <kainino@chromium.org> Reviewed-by: 's avatarJames Darpinian <jdarpinian@chromium.org> Commit-Queue: Kenneth Russell <kbr@chromium.org>
parent 81ee4d29
...@@ -21,6 +21,10 @@ ...@@ -21,6 +21,10 @@
# include <android/log.h> # include <android/log.h>
#endif #endif
#if defined(ANGLE_PLATFORM_APPLE)
# include <os/log.h>
#endif
#include "anglebase/no_destructor.h" #include "anglebase/no_destructor.h"
#include "common/Optional.h" #include "common/Optional.h"
#include "common/angleutils.h" #include "common/angleutils.h"
...@@ -228,6 +232,30 @@ void Trace(LogSeverity severity, const char *message) ...@@ -228,6 +232,30 @@ void Trace(LogSeverity severity, const char *message)
} }
__android_log_print(android_priority, "ANGLE", "%s: %s\n", LogSeverityName(severity), __android_log_print(android_priority, "ANGLE", "%s: %s\n", LogSeverityName(severity),
str.c_str()); str.c_str());
#elif defined(ANGLE_PLATFORM_APPLE)
if (__builtin_available(macOS 10.12, iOS 10.0, *))
{
os_log_type_t apple_log_type = OS_LOG_TYPE_DEFAULT;
switch (severity)
{
case LOG_INFO:
apple_log_type = OS_LOG_TYPE_INFO;
break;
case LOG_WARN:
apple_log_type = OS_LOG_TYPE_DEFAULT;
break;
case LOG_ERR:
apple_log_type = OS_LOG_TYPE_ERROR;
break;
case LOG_FATAL:
// OS_LOG_TYPE_FAULT is too severe - grabs the entire process tree.
apple_log_type = OS_LOG_TYPE_ERROR;
break;
default:
UNREACHABLE();
}
os_log_with_type(OS_LOG_DEFAULT, apple_log_type, "ANGLE: %s: %s\n", LogSeverityName(severity), str.c_str());
}
#else #else
// Note: we use fprintf because <iostream> includes static initializers. // Note: we use fprintf because <iostream> includes static initializers.
fprintf((severity >= LOG_ERR) ? stderr : stdout, "%s: %s\n", LogSeverityName(severity), fprintf((severity >= LOG_ERR) ? stderr : stdout, "%s: %s\n", LogSeverityName(severity),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment