Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 7 additions & 14 deletions lib/ui/dart_runtime_hooks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,6 @@
#include <android/log.h>
#endif

#if __APPLE__
extern "C" {
// Cannot import the syslog.h header directly because of macro collision
extern void syslog(int, const char*, ...);
}
#endif

using tonic::LogIfError;
using tonic::ToDart;

Expand Down Expand Up @@ -146,18 +139,18 @@ void Logger_PrintString(Dart_NativeArguments args) {
if (Dart_IsError(result)) {
Dart_PropagateError(result);
} else {
// Uses fwrite to support printing NUL bytes.
fwrite(chars, 1, length, stdout);
fputs("\n", stdout);
fflush(stdout);
#if defined(OS_ANDROID)
// In addition to writing to the stdout, write to the logcat so that the
// message is discoverable when running on an unrooted device.
// Write to the logcat on Android.
const char* tag = Settings::Get().log_tag.c_str();
__android_log_print(ANDROID_LOG_INFO, tag, "%.*s", (int)length,
chars);
#elif __APPLE__
syslog(1 /* LOG_ALERT */, "%.*s", (int)length, chars);
// Write directly to stdout on iOS, which is redirected to ASL via
// RedirectIOConnectionsToSyslog in platform_mac.mm.
// TODO(cbracken) replace with dedicated (non-stdout) logging.
fwrite(chars, 1, length, stdout);
fputs("\n", stdout);
fflush(stdout);
#endif
}
if (dart::bin::ShouldCaptureStdout()) {
Expand Down