|
10 | 10 | #include <iostream> |
11 | 11 | #include <sstream> |
12 | 12 |
|
| 13 | +#include "flutter/fml/logging.h" |
13 | 14 | #include "flutter/fml/platform/win/wstring_conversion.h" |
14 | 15 | #include "flutter/shell/platform/common/client_wrapper/binary_messenger_impl.h" |
15 | 16 | #include "flutter/shell/platform/common/path_utils.h" |
@@ -156,17 +157,18 @@ FlutterWindowsEngine::FlutterWindowsEngine(const FlutterProjectBundle& project) |
156 | 157 | embedder_api_.struct_size = sizeof(FlutterEngineProcTable); |
157 | 158 | FlutterEngineGetProcAddresses(&embedder_api_); |
158 | 159 |
|
159 | | - task_runner_ = std::make_unique<TaskRunner>( |
160 | | - embedder_api_.GetCurrentTime, [this](const auto* task) { |
161 | | - if (!engine_) { |
162 | | - std::cerr << "Cannot post an engine task when engine is not running." |
163 | | - << std::endl; |
164 | | - return; |
165 | | - } |
166 | | - if (embedder_api_.RunTask(engine_, task) != kSuccess) { |
167 | | - std::cerr << "Failed to post an engine task." << std::endl; |
168 | | - } |
169 | | - }); |
| 160 | + task_runner_ = |
| 161 | + std::make_unique<TaskRunner>( |
| 162 | + embedder_api_.GetCurrentTime, [this](const auto* task) { |
| 163 | + if (!engine_) { |
| 164 | + FML_LOG(ERROR) |
| 165 | + << "Cannot post an engine task when engine is not running."; |
| 166 | + return; |
| 167 | + } |
| 168 | + if (embedder_api_.RunTask(engine_, task) != kSuccess) { |
| 169 | + FML_LOG(ERROR) << "Failed to post an engine task."; |
| 170 | + } |
| 171 | + }); |
170 | 172 |
|
171 | 173 | // Set up the legacy structs backing the API handles. |
172 | 174 | messenger_ = std::make_unique<FlutterDesktopMessenger>(); |
@@ -206,15 +208,15 @@ bool FlutterWindowsEngine::Run() { |
206 | 208 |
|
207 | 209 | bool FlutterWindowsEngine::Run(std::string_view entrypoint) { |
208 | 210 | if (!project_->HasValidPaths()) { |
209 | | - std::cerr << "Missing or unresolvable paths to assets." << std::endl; |
| 211 | + FML_LOG(ERROR) << "Missing or unresolvable paths to assets."; |
210 | 212 | return false; |
211 | 213 | } |
212 | 214 | std::string assets_path_string = project_->assets_path().u8string(); |
213 | 215 | std::string icu_path_string = project_->icu_path().u8string(); |
214 | 216 | if (embedder_api_.RunsAOTCompiledDartCode()) { |
215 | 217 | aot_data_ = project_->LoadAotData(embedder_api_); |
216 | 218 | if (!aot_data_) { |
217 | | - std::cerr << "Unable to start engine without AOT data." << std::endl; |
| 219 | + FML_LOG(ERROR) << "Unable to start engine without AOT data."; |
218 | 220 | return false; |
219 | 221 | } |
220 | 222 | } |
@@ -272,10 +274,9 @@ bool FlutterWindowsEngine::Run(std::string_view entrypoint) { |
272 | 274 | // method and only the entrypoint specified in project_ should be used. |
273 | 275 | if (!project_->dart_entrypoint().empty() && !entrypoint.empty() && |
274 | 276 | project_->dart_entrypoint() != entrypoint) { |
275 | | - std::cerr << "Conflicting entrypoints were specified in " |
276 | | - "FlutterDesktopEngineProperties.dart_entrypoint and " |
277 | | - "FlutterDesktopEngineRun(engine, entry_point). " |
278 | | - << std::endl; |
| 277 | + FML_LOG(ERROR) << "Conflicting entrypoints were specified in " |
| 278 | + "FlutterDesktopEngineProperties.dart_entrypoint and " |
| 279 | + "FlutterDesktopEngineRun(engine, entry_point). "; |
279 | 280 | return false; |
280 | 281 | } |
281 | 282 | if (!entrypoint.empty()) { |
@@ -339,8 +340,7 @@ bool FlutterWindowsEngine::Run(std::string_view entrypoint) { |
339 | 340 | auto result = embedder_api_.Run(FLUTTER_ENGINE_VERSION, &renderer_config, |
340 | 341 | &args, this, &engine_); |
341 | 342 | if (result != kSuccess || engine_ == nullptr) { |
342 | | - std::cerr << "Failed to start Flutter engine: error " << result |
343 | | - << std::endl; |
| 343 | + FML_LOG(ERROR) << "Failed to start Flutter engine: error " << result; |
344 | 344 | return false; |
345 | 345 | } |
346 | 346 |
|
@@ -454,7 +454,7 @@ bool FlutterWindowsEngine::SendPlatformMessage( |
454 | 454 | embedder_api_.PlatformMessageCreateResponseHandle( |
455 | 455 | engine_, reply, user_data, &response_handle); |
456 | 456 | if (result != kSuccess) { |
457 | | - std::cout << "Failed to create response handle\n"; |
| 457 | + FML_LOG(ERROR) << "Failed to create response handle"; |
458 | 458 | return false; |
459 | 459 | } |
460 | 460 | } |
@@ -486,9 +486,9 @@ void FlutterWindowsEngine::SendPlatformMessageResponse( |
486 | 486 | void FlutterWindowsEngine::HandlePlatformMessage( |
487 | 487 | const FlutterPlatformMessage* engine_message) { |
488 | 488 | if (engine_message->struct_size != sizeof(FlutterPlatformMessage)) { |
489 | | - std::cerr << "Invalid message size received. Expected: " |
490 | | - << sizeof(FlutterPlatformMessage) << " but received " |
491 | | - << engine_message->struct_size << std::endl; |
| 489 | + FML_LOG(ERROR) << "Invalid message size received. Expected: " |
| 490 | + << sizeof(FlutterPlatformMessage) << " but received " |
| 491 | + << engine_message->struct_size; |
492 | 492 | return; |
493 | 493 | } |
494 | 494 |
|
|
0 commit comments