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
17 changes: 13 additions & 4 deletions lib/ui/dart_runtime_hooks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@

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

using tonic::LogIfError;
Expand Down Expand Up @@ -143,11 +148,15 @@ void Logger_PrintString(Dart_NativeArguments args) {
// 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 defined(OS_IOS)
// Write to syslog on iOS.
//
// TODO(cbracken): replace with dedicated communication channel and bypass
// iOS logging APIs altogether.
syslog(1 /* LOG_ALERT */, "%.*s", (int)length, chars);
#else
// On Fuchsia, iOS and in flutter_tester (on both macOS and Linux), write
// directly to stdout. On iOS, this is redirected to ASL via
// RedirectIOConnectionsToSyslog in platform_mac.mm.
// TODO(cbracken): replace with dedicated (non-stdout) logging on iOS.
// On Fuchsia and in flutter_tester (on both macOS and Linux), write
// directly to stdout.
fwrite(chars, 1, length, stdout);
fputs("\n", stdout);
fflush(stdout);
Expand Down
5 changes: 0 additions & 5 deletions shell/common/switches.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,6 @@ 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
15 changes: 0 additions & 15 deletions shell/platform/darwin/common/platform_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

#include <Foundation/Foundation.h>

#include <asl.h>

#include "dart/runtime/include/dart_tools_api.h"
#include "flutter/common/threads.h"
#include "flutter/fml/trace_event.h"
Expand All @@ -20,17 +18,6 @@

namespace shell {

static void RedirectIOConnectionsToSyslog(const ftl::CommandLine& command_line) {
#if TARGET_OS_IPHONE
if (command_line.HasOption(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 ftl::CommandLine InitializedCommandLine() {
std::vector<std::string> args_vector;

Expand All @@ -54,8 +41,6 @@ static void RedirectIOConnectionsToSyslog(const ftl::CommandLine& command_line)

auto command_line = InitializedCommandLine();

RedirectIOConnectionsToSyslog(command_line);

// This is about as early as tracing of any kind can start. Add an instant
// marker that can be used as a reference for startup.
TRACE_EVENT_INSTANT0("flutter", "main");
Expand Down