Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
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
7 changes: 2 additions & 5 deletions lib/ui/dart_runtime_hooks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@
#endif

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

using tonic::LogIfError;
Expand Down Expand Up @@ -157,7 +154,7 @@ void Logger_PrintString(Dart_NativeArguments args) {
__android_log_print(ANDROID_LOG_INFO, tag, "%.*s", (int)length,
chars);
#elif __APPLE__
syslog(1 /* LOG_ALERT */, "%.*s", (int)length, chars);
asl_log_message(ASL_LEVEL_NOTICE, "%.*s", (int)length, chars);
#endif
}
if (dart::bin::ShouldCaptureStdout()) {
Expand Down
5 changes: 5 additions & 0 deletions shell/common/switches.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ DEF_SWITCH(NonInteractive,
"non-interactive",
"Make the shell non-interactive. By default, the shell attempts "
"to setup a window and create an OpenGL context.")
DEF_SWITCH(NoRedirectToSyslog,
"no-redirect-to-syslog",
"On iOS: Don't redirect stdout and stderr to syslog by default. "
"This is used by the tools to read device logs. However, this can "
"cause logs to not show up when launched from Xcode.")
DEF_SWITCH(Packages, "packages", "Specify the path to the packages.")
DEF_SWITCH(StartPaused,
"start-paused",
Expand Down
16 changes: 16 additions & 0 deletions shell/platform/darwin/common/platform_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,20 @@ static void InitializeLogging() {
false); // Tick count
}

static void RedirectIOConnectionsToSyslog() {
#if TARGET_OS_IPHONE
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
FlagForSwitch(Switch::NoRedirectToSyslog))) {
return;
}

asl_log_descriptor(NULL, NULL, ASL_LEVEL_NOTICE, STDOUT_FILENO,
ASL_LOG_DESCRIPTOR_WRITE);
asl_log_descriptor(NULL, NULL, ASL_LEVEL_WARNING, STDERR_FILENO,
ASL_LOG_DESCRIPTOR_WRITE);
#endif
}

static void InitializeCommandLine() {
base::mac::ScopedNSAutoreleasePool pool;
base::CommandLine::StringVector vector;
Expand Down Expand Up @@ -63,6 +77,8 @@ static void InitializeCommandLine() {

InitializeCommandLine();

RedirectIOConnectionsToSyslog();

InitializeLogging();

base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess();
Expand Down