diff --git a/engine/src/flutter/lib/ui/ui_dart_state.cc b/engine/src/flutter/lib/ui/ui_dart_state.cc index f4022b04af..9ff5c009ad 100644 --- a/engine/src/flutter/lib/ui/ui_dart_state.cc +++ b/engine/src/flutter/lib/ui/ui_dart_state.cc @@ -4,7 +4,6 @@ #include "flutter/lib/ui/ui_dart_state.h" -#include #include #include "flutter/fml/message_loop.h" @@ -13,15 +12,6 @@ #include "third_party/tonic/converter/dart_converter.h" #include "third_party/tonic/dart_message_handler.h" -#if defined(FML_OS_ANDROID) -#include -#elif defined(FML_OS_IOS) -extern "C" { -// Cannot import the syslog.h header directly because of macro collision. -extern void syslog(int, const char*, ...); -} -#endif - using tonic::ToDart; namespace flutter { @@ -219,26 +209,6 @@ void UIDartState::LogMessage(const std::string& tag, const std::string& message) const { if (log_message_callback_) { log_message_callback_(tag, message); - } else { - // Fall back to previous behavior if unspecified. -#if defined(FML_OS_ANDROID) - __android_log_print(ANDROID_LOG_INFO, tag.c_str(), "%.*s", - static_cast(message.size()), message.c_str()); -#elif defined(FML_OS_IOS) - std::stringstream stream; - if (!tag.empty()) { - stream << tag << ": "; - } - stream << message; - std::string log = stream.str(); - syslog(1 /* LOG_ALERT */, "%.*s", static_cast(log.size()), - log.c_str()); -#else - if (!tag.empty()) { - std::cout << tag << ": "; - } - std::cout << message << std::endl; -#endif } } diff --git a/engine/src/flutter/shell/platform/embedder/embedder.cc b/engine/src/flutter/shell/platform/embedder/embedder.cc index 8d36f33a38..2c55865c79 100644 --- a/engine/src/flutter/shell/platform/embedder/embedder.cc +++ b/engine/src/flutter/shell/platform/embedder/embedder.cc @@ -2093,6 +2093,8 @@ FlutterEngineResult FlutterEngineInitialize(size_t version, settings.root_isolate_create_callback = [callback, user_data](const auto& isolate) { callback(user_data); }; } + + // Wire up callback for engine and print logging. if (SAFE_ACCESS(args, log_message_callback, nullptr) != nullptr) { FlutterLogMessageCallback callback = SAFE_ACCESS(args, log_message_callback, nullptr); @@ -2101,7 +2103,17 @@ FlutterEngineResult FlutterEngineInitialize(size_t version, const std::string& message) { callback(tag.c_str(), message.c_str(), user_data); }; + } else { + settings.log_message_callback = [](const std::string& tag, + const std::string& message) { + // Fall back to logging to stdout if unspecified. + if (tag.empty()) { + std::cout << tag << ": "; + } + std::cout << message << std::endl; + }; } + if (SAFE_ACCESS(args, log_tag, nullptr) != nullptr) { settings.log_tag = SAFE_ACCESS(args, log_tag, nullptr); }