Skip to content

Commit fd17ef9

Browse files
committed
Separate logging threads for stdout and stderr (#41)
* Format files * Separate stdout and stderr in dlog output
1 parent 91b1a4d commit fd17ef9

19 files changed

+98
-74
lines changed

shell/platform/tizen/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ source_set("flutter_tizen") {
5050
"key_event_handler.cc",
5151
"tizen_embedder_engine.cc",
5252
"tizen_event_loop.cc",
53+
"tizen_log.cc",
5354
"tizen_renderer.cc",
5455
"tizen_vsync_waiter.cc",
5556
"touch_event_handler.cc",

shell/platform/tizen/channels/lifecycle_channel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ class LifecycleChannel {
2020
private:
2121
FLUTTER_API_SYMBOL(FlutterEngine) flutter_engine_;
2222
};
23+
2324
#endif // EMBEDDER_LIFECYCLE_CHANNEL_H_

shell/platform/tizen/channels/platform_view_channel.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ std::string ExtractStringFromMap(const flutter::EncodableValue& arguments,
2424
}
2525
return std::string();
2626
}
27+
2728
int ExtractIntFromMap(const flutter::EncodableValue& arguments,
2829
const char* key) {
2930
if (std::holds_alternative<flutter::EncodableMap>(arguments)) {
@@ -33,6 +34,7 @@ int ExtractIntFromMap(const flutter::EncodableValue& arguments,
3334
}
3435
return -1;
3536
}
37+
3638
double ExtractDoubleFromMap(const flutter::EncodableValue& arguments,
3739
const char* key) {
3840
if (std::holds_alternative<flutter::EncodableMap>(arguments)) {

shell/platform/tizen/channels/settings_channel.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ static constexpr char PLATFORM_BRIGHTNESS[] = "platformBrightness";
1212
SettingsChannel::SettingsChannel(flutter::BinaryMessenger* messenger)
1313
: channel_(
1414
std::make_unique<flutter::BasicMessageChannel<rapidjson::Document>>(
15-
messenger,
16-
CHANNEL_NAME,
15+
messenger, CHANNEL_NAME,
1716
&flutter::JsonMessageCodec::GetInstance())) {
1817
system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR,
1918
OnSettingsChangedCallback, this);

shell/platform/tizen/channels/settings_channel.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#define EMBEDDER_SETTINGS_CHANNEL_H_
77

88
#include <system/system_settings.h>
9+
910
#include "flutter/shell/platform/common/cpp/client_wrapper/include/flutter/basic_message_channel.h"
1011
#include "flutter/shell/platform/common/cpp/client_wrapper/include/flutter/binary_messenger.h"
1112
#include "flutter/shell/platform/common/cpp/json_message_codec.h"
@@ -22,4 +23,5 @@ class SettingsChannel {
2223
void* user_data);
2324
void SendSettingsEvent();
2425
};
26+
2527
#endif // EMBEDDER_SETTINGS_CHANNEL_H_

shell/platform/tizen/channels/text_input_channel.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
#include "flutter/shell/platform/tizen/tizen_embedder_engine.h"
1111
#include "flutter/shell/platform/tizen/tizen_log.h"
12-
#include "stdlib.h"
13-
#include "string.h"
1412

1513
static constexpr char kSetEditingStateMethod[] = "TextInput.setEditingState";
1614
static constexpr char kClearClientMethod[] = "TextInput.clearClient";

shell/platform/tizen/channels/text_input_channel.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
#ifndef EMBEDDER_TEXT_INPUT_PLUGIN_H_
6-
#define EMBEDDER_TEXT_INPUT_PLUGIN_H_
5+
#ifndef EMBEDDER_TEXT_INPUT_CHANNEL_H_
6+
#define EMBEDDER_TEXT_INPUT_CHANNEL_H_
77

88
#define EFL_BETA_API_SUPPORT
99
#include <Ecore_IMF.h>
@@ -82,4 +82,5 @@ class TextInputChannel {
8282
TizenEmbedderEngine* engine_;
8383
SoftwareKeyboardGeometry current_keyboard_geometry_;
8484
};
85-
#endif
85+
86+
#endif // EMBEDDER_TEXT_INPUT_CHANNEL_H_

shell/platform/tizen/flutter_tizen.cc

Lines changed: 2 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55

66
#include "public/flutter_tizen.h"
77

8-
#include <inttypes.h>
9-
#include <unistd.h>
10-
118
#include "flutter/shell/platform/common/cpp/client_wrapper/include/flutter/plugin_registrar.h"
129
#include "flutter/shell/platform/common/cpp/client_wrapper/include/flutter/standard_message_codec.h"
1310
#include "flutter/shell/platform/common/cpp/incoming_message_dispatcher.h"
@@ -21,62 +18,10 @@ struct FlutterWindowControllerState {
2118
std::unique_ptr<TizenEmbedderEngine> engine;
2219
};
2320

24-
// The pipe used for logging to dlog.
25-
static int logging_pipe[2];
26-
// The thread that constantly writes out stdout to dlog through the pipe.
27-
// Only one logging thread should exist per process.
28-
static pthread_t logging_thread;
29-
30-
static void* LoggingFunction(void*) {
31-
ssize_t size;
32-
char buffer[1024];
33-
34-
while ((size = read(logging_pipe[0], buffer, sizeof(buffer) - 1)) > 0) {
35-
buffer[size] = 0;
36-
__dlog_print(LOG_ID_MAIN, DLOG_INFO, LOG_TAG, "%s", buffer);
37-
}
38-
39-
close(logging_pipe[0]);
40-
close(logging_pipe[1]);
41-
42-
return nullptr;
43-
}
44-
45-
// Redirects the process's standard output/error to dlog for use by the flutter
46-
// tools.
47-
bool InitializeLogging() {
48-
if (logging_thread) {
49-
FT_LOGD("The logging thread already exists.");
50-
return true;
51-
}
52-
53-
if (pipe(logging_pipe) < 0) {
54-
FT_LOGE("Failed to create a pipe.");
55-
return false;
56-
}
57-
58-
if (dup2(logging_pipe[1], 1) < 0 || dup2(logging_pipe[1], 2) < 0) {
59-
FT_LOGE("Failed to duplicate file descriptors.");
60-
return false;
61-
}
62-
63-
if (pthread_create(&logging_thread, 0, LoggingFunction, 0) != 0) {
64-
FT_LOGE("Failed to create a logging thread.");
65-
logging_thread = 0;
66-
return false;
67-
}
68-
69-
if (pthread_detach(logging_thread) != 0) {
70-
FT_LOGE("Failed to detach the logging thread.");
71-
return false;
72-
}
73-
return true;
74-
}
75-
7621
FlutterWindowControllerRef FlutterCreateWindow(
7722
const FlutterWindowProperties& window_properties,
7823
const FlutterEngineProperties& engine_properties) {
79-
InitializeLogging();
24+
StartLogging();
8025

8126
auto state = std::make_unique<FlutterWindowControllerState>();
8227
state->engine = std::make_unique<TizenEmbedderEngine>(window_properties);
@@ -221,6 +166,7 @@ void FlutterNotifyLowMemoryWarning(FlutterWindowControllerRef controller) {
221166

222167
void FlutterRotateWindow(FlutterWindowControllerRef controller,
223168
int32_t degree) {
169+
FT_LOGW("Deprecated API. Use SystemChrome.setPreferredOrientations instead.");
224170
}
225171

226172
int64_t FlutterRegisterExternalTexture(

shell/platform/tizen/public/flutter_platform_view.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,4 @@ FLUTTER_EXPORT void FlutterRegisterViewFactory(
7979
} // extern "C"
8080
#endif
8181

82-
#endif // FLUTTER_SHELL_PLATFORM_TIZEN_PUBLIC_FLUTTER_PLATFORM_VIEW_H_
82+
#endif // FLUTTER_SHELL_PLATFORM_TIZEN_PUBLIC_FLUTTER_PLATFORM_VIEW_H_

shell/platform/tizen/public/flutter_texture_registrar.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ FLUTTER_EXPORT bool FlutterMarkExternalTextureFrameAvailable(
4040
} // extern "C"
4141
#endif
4242

43-
#endif // FLUTTER_SHELL_PLATFORM_TIZEN_PUBLIC_FLUTTER_TEXTURE_REGISTRAR_H_
43+
#endif // FLUTTER_SHELL_PLATFORM_TIZEN_PUBLIC_FLUTTER_TEXTURE_REGISTRAR_H_

0 commit comments

Comments
 (0)