Skip to content

Commit

Permalink
FlipperClient log format
Browse files Browse the repository at this point in the history
Summary: Use the same standard used in other places.

Reviewed By: ivanmisuno

Differential Revision: D49228128

fbshipit-source-id: 771b6923f758400200298f3339b83b2c4d51648b
  • Loading branch information
lblasa authored and facebook-github-bot committed Sep 19, 2023
1 parent 7f355dd commit 54f5b1b
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions xplat/Flipper/FlipperClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,20 @@ FlipperClient* FlipperClient::instance() {
void FlipperClient::setStateListener(
std::shared_ptr<FlipperStateUpdateListener> stateListener) {
performAndReportError([this, &stateListener]() {
log("Setting state listener");
log("[client] Set state listener");
flipperState_->setUpdateListener(stateListener);
});
}

void FlipperClient::addPlugin(std::shared_ptr<FlipperPlugin> plugin) {
performAndReportError([this, plugin]() {
log("FlipperClient::addPlugin " + plugin->identifier());
log("[client] Add plugin " + plugin->identifier());
auto step = flipperState_->start("Add plugin " + plugin->identifier());
auto needs_refresh = false;

std::lock_guard<std::mutex> lock(mutex_);
if (plugins_.find(plugin->identifier()) != plugins_.end()) {
log("plugin " + plugin->identifier() + " already added.");
log("[client] Plugin " + plugin->identifier() + " already added");
} else {
plugins_[plugin->identifier()] = plugin;
needs_refresh = true;
Expand All @@ -78,7 +78,6 @@ void FlipperClient::addPlugin(std::shared_ptr<FlipperPlugin> plugin) {
void FlipperClient::setCertificateProvider(
const std::shared_ptr<FlipperCertificateProvider> provider) {
socket_->setCertificateProvider(provider);
log("cpp setCertificateProvider called");
}

std::shared_ptr<FlipperCertificateProvider>
Expand All @@ -88,11 +87,11 @@ FlipperClient::getCertificateProvider() {

void FlipperClient::removePlugin(std::shared_ptr<FlipperPlugin> plugin) {
performAndReportError([this, plugin]() {
log("FlipperClient::removePlugin " + plugin->identifier());
log("[client] Remove plugin: " + plugin->identifier());

std::lock_guard<std::mutex> lock(mutex_);
if (plugins_.find(plugin->identifier()) == plugins_.end()) {
log("plugin " + plugin->identifier() + " not added.");
log("[client] Plugin " + plugin->identifier() + " not added");
return;
}
disconnect(plugin);
Expand Down Expand Up @@ -143,7 +142,7 @@ void FlipperClient::refreshPlugins() {

void FlipperClient::onConnected() {
performAndReportError([this]() {
log("FlipperClient::onConnected");
log("[client] connected");

std::lock_guard<std::mutex> lock(mutex_);
connected_ = true;
Expand All @@ -152,7 +151,7 @@ void FlipperClient::onConnected() {

void FlipperClient::onDisconnected() {
performAndReportError([this]() {
log("FlipperClient::onDisconnected");
log("[client] disconnected");
auto step = flipperState_->start("Trigger onDisconnected callbacks");
std::lock_guard<std::mutex> lock(mutex_);
connected_ = false;
Expand Down Expand Up @@ -280,7 +279,7 @@ void FlipperClient::onMessageReceived(
"stacktrace", callstack())("name", e.what()));
}
} catch (...) {
log("Unknown error suppressed in FlipperClient");
log("[client] Unknown error suppressed");
if (responder) {
responder->error(dynamic::object(
"message",
Expand Down Expand Up @@ -333,7 +332,7 @@ void FlipperClient::performAndReportError(const std::function<void()>& func) {
} catch (...) {
// Generic catch block for the exception of type not belonging to
// std::exception
log("Unknown error suppressed in FlipperClient");
log("[client] Unknown error suppressed");
}
#endif
}
Expand All @@ -347,7 +346,7 @@ void FlipperClient::handleError(std::exception& e) {
"name", e.what()));
socket_->sendMessage(message);
} else {
log("Error: " + std::string(e.what()));
log("[client] Error: " + std::string(e.what()));
}
}

Expand Down

0 comments on commit 54f5b1b

Please sign in to comment.