Skip to content

Refactor the logger #144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 20, 2021
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
3 changes: 1 addition & 2 deletions shell/platform/tizen/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ _flutter_tizen_source = [
"flutter_tizen_engine.cc",
"flutter_tizen_texture_registrar.cc",
"key_event_handler.cc",
"logger.cc",
"tizen_event_loop.cc",
"tizen_input_method_context.cc",
"tizen_renderer.cc",
Expand Down Expand Up @@ -133,7 +134,6 @@ template("embedder_for_profile") {
"external_texture_pixel_gl.cc",
"external_texture_surface_gl.cc",
"system_utils_tizen.cc",
"tizen_log.cc",
]

libs = _libs_minimum
Expand Down Expand Up @@ -250,7 +250,6 @@ template("embedder_executable") {
"external_texture_pixel_gl_stub.cc",
"external_texture_surface_gl_stub.cc",
"system_utils_linux.cc",
"tizen_log_stub.cc",
"tizen_renderer_evas_gl.cc",
]

Expand Down
1 change: 0 additions & 1 deletion shell/platform/tizen/channels/key_event_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <map>

#include "flutter/shell/platform/common/json_message_codec.h"
#include "flutter/shell/platform/tizen/tizen_log.h"

namespace flutter {

Expand Down
10 changes: 5 additions & 5 deletions shell/platform/tizen/channels/lifecycle_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "lifecycle_channel.h"

#include "flutter/shell/platform/tizen/channels/string_codec.h"
#include "flutter/shell/platform/tizen/tizen_log.h"
#include "flutter/shell/platform/tizen/logger.h"

namespace flutter {

Expand All @@ -29,22 +29,22 @@ LifecycleChannel::LifecycleChannel(BinaryMessenger* messenger)
LifecycleChannel::~LifecycleChannel() {}

void LifecycleChannel::AppIsInactive() {
FT_LOGI("Sending %s message.", kInactive);
FT_LOG(Info) << "Sending " << kInactive << " message.";
channel_->Send(EncodableValue(kInactive));
}

void LifecycleChannel::AppIsResumed() {
FT_LOGI("Sending %s message.", kResumed);
FT_LOG(Info) << "Sending " << kResumed << " message.";
channel_->Send(EncodableValue(kResumed));
}

void LifecycleChannel::AppIsPaused() {
FT_LOGI("Sending %s message.", kPaused);
FT_LOG(Info) << "Sending " << kPaused << " message.";
channel_->Send(EncodableValue(kPaused));
}

void LifecycleChannel::AppIsDetached() {
FT_LOGI("Sending %s message.", kDetached);
FT_LOG(Info) << "Sending " << kDetached << " message.";
channel_->Send(EncodableValue(kDetached));
}

Expand Down
25 changes: 10 additions & 15 deletions shell/platform/tizen/channels/platform_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <map>

#include "flutter/shell/platform/common/json_method_codec.h"
#include "flutter/shell/platform/tizen/tizen_log.h"
#include "flutter/shell/platform/tizen/logger.h"

namespace flutter {

Expand Down Expand Up @@ -99,12 +99,7 @@ class FeedbackManager {
FeedbackManager& operator=(const FeedbackManager&) = delete;

ResultCode Play(FeedbackType type, FeedbackPattern pattern) {
FT_LOGI("Enter FeedbackManager::Play(): type: [%d], pattern: [%d]",
static_cast<int>(type), static_cast<int>(pattern));

if (ResultCode::kOk != initialization_status_) {
FT_LOGE("Cannot run Play(): initialization_status_: [%d]",
static_cast<int>(initialization_status_));
return initialization_status_;
}

Expand All @@ -113,8 +108,8 @@ class FeedbackManager {
if (FEEDBACK_ERROR_NONE == ret) {
return ResultCode::kOk;
}
FT_LOGE("feedback_play_type() failed with error: [%d] (%s)", ret,
get_error_message(ret));
FT_LOG(Error) << "feedback_play_type() failed with error: "
<< get_error_message(ret);

return NativeErrorToResultCode(ret);
}
Expand All @@ -139,8 +134,8 @@ class FeedbackManager {
FeedbackManager() {
auto ret = feedback_initialize();
if (FEEDBACK_ERROR_NONE != ret) {
FT_LOGE("feedback_initialize() failed with error: [%d] (%s)", ret,
get_error_message(ret));
FT_LOG(Error) << "feedback_initialize() failed with error: "
<< get_error_message(ret);
initialization_status_ = NativeErrorToResultCode(ret);
return;
}
Expand All @@ -151,8 +146,8 @@ class FeedbackManager {
~FeedbackManager() {
auto ret = feedback_deinitialize();
if (FEEDBACK_ERROR_NONE != ret) {
FT_LOGE("feedback_deinitialize() failed with error: [%d] (%s)", ret,
get_error_message(ret));
FT_LOG(Error) << "feedback_deinitialize() failed with error: "
<< get_error_message(ret);
return;
}
}
Expand Down Expand Up @@ -252,7 +247,7 @@ void PlatformChannel::HandleMethodCall(
const auto error_cause =
FeedbackManager::GetErrorMessage(ret, kPlaySoundMethod, pattern_str);
const std::string error_message = "Could not play sound";
FT_LOGE("%s: %s", error_cause.c_str(), error_message.c_str());
FT_LOG(Error) << error_cause << ": " << error_message;

result->Error(error_cause, error_message);

Expand Down Expand Up @@ -280,7 +275,7 @@ void PlatformChannel::HandleMethodCall(
FeedbackManager::GetErrorMessage(ret, vibrate_variant_name);
const std::string error_message = "Could not vibrate";

FT_LOGE("%s: %s", error_cause.c_str(), error_message.c_str());
FT_LOG(Error) << error_cause << ": " << error_message;

result->Error(error_cause, error_message);
} else if (method == kGetClipboardDataMethod) {
Expand Down Expand Up @@ -330,7 +325,7 @@ void PlatformChannel::HandleMethodCall(
} else if (method == kSetSystemUIOverlayStyleMethod) {
result->NotImplemented();
} else {
FT_LOGI("Unimplemented method: %s", method.c_str());
FT_LOG(Info) << "Unimplemented method: " << method;
result->NotImplemented();
}
}
Expand Down
13 changes: 4 additions & 9 deletions shell/platform/tizen/channels/platform_view_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#include "flutter/shell/platform/common/client_wrapper/include/flutter/standard_method_codec.h"
#include "flutter/shell/platform/common/json_method_codec.h"
#include "flutter/shell/platform/tizen/flutter_tizen_engine.h"
#include "flutter/shell/platform/tizen/logger.h"
#include "flutter/shell/platform/tizen/public/flutter_platform_view.h"
#include "flutter/shell/platform/tizen/tizen_log.h"

namespace flutter {

Expand Down Expand Up @@ -121,9 +121,7 @@ void PlatformViewChannel::HandleMethodCall(
return;
}

FT_LOGI(
"PlatformViewChannel create viewType: %s id: %d width: %f height: %f ",
view_type.c_str(), view_id, width, height);
FT_LOG(Info) << "Creating a platform view: " << view_type;
RemoveViewInstanceIfNeeded(view_id);

EncodableMap values = std::get<EncodableMap>(arguments);
Expand All @@ -149,7 +147,7 @@ void PlatformViewChannel::HandleMethodCall(
result->Error("Can't create a webview instance!!");
}
} else {
FT_LOGE("can't find view type = %s", view_type.c_str());
FT_LOG(Error) << "Can't find view type: " << view_type;
result->Error("Can't find view type");
}
} else if (method == "clearFocus") {
Expand Down Expand Up @@ -228,11 +226,8 @@ void PlatformViewChannel::HandleMethodCall(
}

result->Success();
} else if (method == "setDirection") {
FT_LOGW("PlatformViewChannel setDirection - not implemented");
result->NotImplemented();
} else {
FT_LOGW("Unimplemented method: %s", method.c_str());
FT_LOG(Warn) << "Unimplemented method: " << method;
result->NotImplemented();
}
} else {
Expand Down
29 changes: 15 additions & 14 deletions shell/platform/tizen/channels/text_input_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include "flutter/shell/platform/common/json_method_codec.h"
#include "flutter/shell/platform/tizen/flutter_tizen_engine.h"
#include "flutter/shell/platform/tizen/tizen_log.h"
#include "flutter/shell/platform/tizen/logger.h"

namespace flutter {

Expand Down Expand Up @@ -46,6 +46,7 @@ bool IsASCIIPrintableKey(char c) {
}
return false;
}

} // namespace

TextInputChannel::TextInputChannel(BinaryMessenger* messenger,
Expand All @@ -63,7 +64,7 @@ TextInputChannel::TextInputChannel(BinaryMessenger* messenger,

// Set input method callbacks
input_method_context_->SetOnCommitCallback([this](std::string str) -> void {
FT_LOGI("OnCommit str[%s]", str.data());
FT_LOG(Debug) << "OnCommit: " << str;
text_editing_context_.edit_status_ = EditStatus::kCommit;
ConsumeLastPreedit();
active_model_->AddText(str);
Expand Down Expand Up @@ -95,9 +96,10 @@ TextInputChannel::TextInputChannel(BinaryMessenger* messenger,
active_model_->selection().base();
text_editing_context_.has_preedit_ = true;
SendStateUpdate(*active_model_);
FT_LOGI("preedit start pos[%d], preedit end pos[%d]",
text_editing_context_.preedit_start_pos_,
text_editing_context_.preedit_end_pos_);
FT_LOG(Debug) << "Preedit start position: "
<< text_editing_context_.preedit_start_pos_
<< ", end position: "
<< text_editing_context_.preedit_end_pos_;
}
});

Expand Down Expand Up @@ -133,8 +135,7 @@ void TextInputChannel::HandleMethodCall(
const MethodCall<rapidjson::Document>& method_call,
std::unique_ptr<MethodResult<rapidjson::Document>> result) {
const std::string& method = method_call.method_name();

FT_LOGI("Handle Method : %s", method.data());
FT_LOG(Debug) << "Handle a method: " << method;

if (method.compare(kShowMethod) == 0) {
input_method_context_->ShowInputPannel();
Expand Down Expand Up @@ -253,7 +254,7 @@ void TextInputChannel::SendStateUpdate(const TextInputModel& model) {
kTextKey, rapidjson::Value(model.GetText(), allocator).Move(), allocator);
args->PushBack(editing_state, allocator);

FT_LOGI("Send text[%s]", model.GetText().data());
FT_LOG(Info) << "Send text: " << model.GetText();
channel_->InvokeMethod(kUpdateEditingStateMethod, std::move(args));
}

Expand All @@ -268,7 +269,7 @@ bool TextInputChannel::FilterEvent(Ecore_Event_Key* event) {
// FIXME: Only for wearable.
if (is_ime && strcmp(event->key, "Select") == 0) {
text_editing_context_.is_in_select_mode_ = true;
FT_LOGI("Set select mode[true]");
FT_LOG(Debug) << "Entering select mode.";
}
#else
bool is_ime = strcmp(ecore_device_name_get(event->dev), "ime") == 0;
Expand All @@ -277,7 +278,7 @@ bool TextInputChannel::FilterEvent(Ecore_Event_Key* event) {
if (ShouldNotFilterEvent(event->key, is_ime)) {
ResetTextEditingContext();
input_method_context_->ResetInputMethodContext();
FT_LOGW("Force redirect IME key-event[%s] to fallback", event->keyname);
FT_LOG(Info) << "Force redirect an IME key event: " << event->keyname;
return false;
}

Expand All @@ -292,7 +293,7 @@ bool TextInputChannel::FilterEvent(Ecore_Event_Key* event) {
text_editing_context_.is_in_select_mode_) {
text_editing_context_.is_in_select_mode_ = false;
handled = true;
FT_LOGI("Set select mode[false]");
FT_LOG(Debug) << "Leaving select mode.";
}
#endif

Expand All @@ -303,7 +304,7 @@ void TextInputChannel::HandleUnfilteredEvent(Ecore_Event_Key* event) {
#ifdef MOBILE_PROFILE
// FIXME: Only for mobile.
if (text_editing_context_.edit_status_ == EditStatus::kPreeditEnd) {
FT_LOGW("Ignore key-event[%s]!", event->keyname);
FT_LOG(Warn) << "Ignore a key event: " << event->keyname;
ResetTextEditingContext();
return;
}
Expand Down Expand Up @@ -372,8 +373,8 @@ void TextInputChannel::ConsumeLastPreedit() {
text_editing_context_.preedit_start_pos_;
active_model_->DeleteSurrounding(-count, count);
std::string after = active_model_->GetText();
FT_LOGI("Consume last preedit count:[%d] text:[%s] -> [%s]", count,
before.data(), after.data());
FT_LOG(Debug) << "Last preedit count: " << count << ", text: " << before
<< " -> " << after;
SendStateUpdate(*active_model_);
}
text_editing_context_.has_preedit_ = false;
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/tizen/external_texture_pixel_gl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "flutter/shell/platform/tizen/external_texture_pixel_gl.h"
#include "external_texture_pixel_gl.h"

#ifdef TIZEN_RENDERER_EVAS_GL
#undef EFL_BETA_API_SUPPORT
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/tizen/external_texture_pixel_gl_stub.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "flutter/shell/platform/tizen/external_texture_pixel_gl.h"
#include "external_texture_pixel_gl.h"

namespace flutter {

Expand Down
15 changes: 7 additions & 8 deletions shell/platform/tizen/external_texture_surface_gl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

#include "external_texture_surface_gl.h"

#include "flutter/shell/platform/common/public/flutter_texture_registrar.h"

#ifdef TIZEN_RENDERER_EVAS_GL
#undef EFL_BETA_API_SUPPORT
#include <Evas_GL_GLES3_Helpers.h>
Expand All @@ -20,7 +18,8 @@ EVAS_GL_GLOBAL_GLES3_DECLARE();

#include <tbm_surface.h>

#include "flutter/shell/platform/tizen/tizen_log.h"
#include "flutter/shell/platform/common/public/flutter_texture_registrar.h"
#include "flutter/shell/platform/tizen/logger.h"

namespace flutter {

Expand Down Expand Up @@ -60,20 +59,20 @@ bool ExternalTextureSurfaceGL::PopulateTexture(
const FlutterDesktopGpuBuffer* gpu_buffer =
texture_callback_(width, height, user_data_);
if (!gpu_buffer) {
FT_LOGI("[texture id:%ld] gpu_buffer is null", texture_id_);
FT_LOG(Info) << "gpu_buffer is null for texture ID: " << texture_id_;
return false;
}

if (!gpu_buffer->buffer) {
FT_LOGI("[texture id:%ld] tbm_surface_ is null", texture_id_);
FT_LOG(Info) << "tbm_surface is null for texture ID: " << texture_id_;
return false;
}
const tbm_surface_h tbm_surface =
reinterpret_cast<tbm_surface_h>(const_cast<void*>(gpu_buffer->buffer));

tbm_surface_info_s info;
if (tbm_surface_get_info(tbm_surface, &info) != TBM_SURFACE_ERROR_NONE) {
FT_LOGI("[texture id:%ld] tbm_surface is invalid", texture_id_);
FT_LOG(Info) << "tbm_surface is invalid for texture ID: " << texture_id_;
return false;
}

Expand Down Expand Up @@ -114,8 +113,8 @@ bool ExternalTextureSurfaceGL::PopulateTexture(
EGL_NATIVE_SURFACE_TIZEN, tbm_surface, attribs);

if (!egl_src_image) {
FT_LOGE("[texture id:%ld] egl_src_image create fail!!, errorcode == %d",
texture_id_, eglGetError());
FT_LOG(Error) << "eglCreateImageKHR failed with an error " << eglGetError()
<< " for texture ID: " << texture_id_;
return false;
}
if (state_->gl_texture == 0) {
Expand Down
Loading