Skip to content

Commit e0ebaea

Browse files
Revert "Re-land: Use os_log instead of syslog on Apple platforms (flutter#16549)" (flutter#16558)
This reverts commit 6aacf5e.
1 parent 5fb0116 commit e0ebaea

File tree

2 files changed

+9
-50
lines changed

2 files changed

+9
-50
lines changed

fml/logging.cc

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111

1212
#if defined(OS_ANDROID)
1313
#include <android/log.h>
14-
#elif defined(OS_MACOSX)
15-
#include <os/log.h>
14+
#elif defined(OS_IOS)
1615
#include <syslog.h>
1716
#endif
1817

@@ -82,37 +81,8 @@ LogMessage::~LogMessage() {
8281
break;
8382
}
8483
__android_log_write(priority, "flutter", stream_.str().c_str());
85-
#elif defined(OS_MACOSX)
86-
const char* chars = stream_.str().c_str();
87-
// Unified logging (os_log) became available in iOS 9.0 and syslog stopped
88-
// working in iOS 13.0. idevicesyslog made device syslog available on the
89-
// connected host, but there is no known API to view device unified logging on
90-
// the host. Flutter tool will continue to observe syslog on devices older
91-
// than iOS 13.0 since it provides more logging context, particularly for
92-
// application crashes.
93-
if (__builtin_available(iOS 13.0, macOS 10.11, *)) {
94-
os_log_t engine_log = os_log_create("io.flutter", "engine");
95-
switch (severity_) {
96-
// TODO(flutter/flutter#45931): LogSeverity LOG_INFO and LOG_WARNING
97-
// collide with syslog log level macros.
98-
case 0 /* LOG_INFO */:
99-
os_log_debug(engine_log, "%s", chars);
100-
break;
101-
case 1 /* LOG_WARNING */:
102-
case LOG_ERROR:
103-
os_log_error(engine_log, "%s", chars);
104-
break;
105-
case LOG_FATAL:
106-
os_log_fault(engine_log, "%s", chars);
107-
break;
108-
default:
109-
os_log(engine_log, "%s", chars);
110-
break;
111-
}
112-
} else {
113-
syslog(LOG_ALERT, "%s", chars);
114-
}
115-
84+
#elif defined(OS_IOS)
85+
syslog(LOG_ALERT, "%s", stream_.str().c_str());
11686
#else
11787
std::cerr << stream_.str();
11888
std::cerr.flush();

lib/ui/dart_runtime_hooks.cc

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@
3030

3131
#if defined(OS_ANDROID)
3232
#include <android/log.h>
33-
#elif defined(OS_MACOSX)
34-
#include <os/log.h>
33+
#elif defined(OS_IOS)
3534
extern "C" {
3635
// Cannot import the syslog.h header directly because of macro collision.
3736
extern void syslog(int, const char*, ...);
@@ -200,29 +199,19 @@ void Logger_PrintString(Dart_NativeArguments args) {
200199
// Write to the logcat on Android.
201200
__android_log_print(ANDROID_LOG_INFO, logger_prefix.c_str(), "%.*s",
202201
(int)length, chars);
203-
#elif defined(OS_MACOSX)
202+
#elif defined(OS_IOS)
203+
// Write to syslog on iOS.
204+
//
204205
// TODO(cbracken): replace with dedicated communication channel and bypass
205206
// iOS logging APIs altogether.
206-
//
207-
// Unified logging (os_log) became available in iOS 9.0 and syslog stopped
208-
// working in iOS 13.0. idevicesyslog made device syslog available on the
209-
// connected host, but there is no known API to view device unified logging
210-
// on the host. Flutter tool will continue to observe syslog on devices
211-
// older than iOS 13.0 since it provides more logging context, particularly
212-
// for application crashes.
213-
if (__builtin_available(iOS 13.0, macOS 10.11, *)) {
214-
os_log_t dart_log = os_log_create("io.flutter", "dart");
215-
os_log(dart_log, "%.*s", static_cast<int>(length), chars);
216-
} else {
217-
syslog(1 /* LOG_ALERT */, "%.*s", static_cast<int>(length), chars);
218-
}
207+
syslog(1 /* LOG_ALERT */, "%.*s", (int)length, chars);
219208
#else
220209
std::cout << log_string << std::endl;
221210
#endif
222211
}
223212

224213
if (dart::bin::ShouldCaptureStdout()) {
225-
// Report print output on the Stdout stream.
214+
// For now we report print output on the Stdout stream.
226215
uint8_t newline[] = {'\n'};
227216
Dart_ServiceSendDataEvent("Stdout", "WriteEvent",
228217
reinterpret_cast<const uint8_t*>(chars), length);

0 commit comments

Comments
 (0)