Add optional debug log switch
Summary: This won't affect runtime, but is useful when debugging issues with flipper itself. Setting this flag means all state changes will be output in logcat. Reviewed By: passy Differential Revision: D10231148 fbshipit-source-id: 7ddd490290ad973fc339b2f5f93a6f9a1fab4577
This commit is contained in:
committed by
Facebook Github Bot
parent
57752533a6
commit
1be54ebee1
@@ -10,19 +10,25 @@
|
|||||||
#include "FlipperStep.h"
|
#include "FlipperStep.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#if FLIPPER_DEBUG_LOG
|
||||||
|
#include "Log.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
using namespace facebook::flipper;
|
using namespace facebook::flipper;
|
||||||
|
|
||||||
/* Class responsible for collecting state updates and combining them into a
|
/* Class responsible for collecting state updates and combining them into a
|
||||||
* view of the current state of the flipper client. */
|
* view of the current state of the flipper client. */
|
||||||
|
|
||||||
|
FlipperState::FlipperState() : logs("") {}
|
||||||
FlipperState::FlipperState(): log("") {}
|
|
||||||
void FlipperState::setUpdateListener(
|
void FlipperState::setUpdateListener(
|
||||||
std::shared_ptr<FlipperStateUpdateListener> listener) {
|
std::shared_ptr<FlipperStateUpdateListener> listener) {
|
||||||
mListener = listener;
|
mListener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FlipperState::started(std::string step) {
|
void FlipperState::started(std::string step) {
|
||||||
|
#if FLIPPER_DEBUG_LOG
|
||||||
|
log("[started] " + step);
|
||||||
|
#endif
|
||||||
if (stateMap.find(step) == stateMap.end()) {
|
if (stateMap.find(step) == stateMap.end()) {
|
||||||
insertOrder.push_back(step);
|
insertOrder.push_back(step);
|
||||||
}
|
}
|
||||||
@@ -33,7 +39,10 @@ void FlipperState::started(std::string step) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FlipperState::success(std::string step) {
|
void FlipperState::success(std::string step) {
|
||||||
log = log + "[Success] " + step + "\n";
|
#if FLIPPER_DEBUG_LOG
|
||||||
|
log("[finished] " + step);
|
||||||
|
#endif
|
||||||
|
logs = logs + "[Success] " + step + "\n";
|
||||||
stateMap[step] = State::success;
|
stateMap[step] = State::success;
|
||||||
if (mListener) {
|
if (mListener) {
|
||||||
mListener->onUpdate();
|
mListener->onUpdate();
|
||||||
@@ -41,7 +50,10 @@ void FlipperState::success(std::string step) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FlipperState::failed(std::string step, std::string errorMessage) {
|
void FlipperState::failed(std::string step, std::string errorMessage) {
|
||||||
log = log + "[Failed] " + step + ": " + errorMessage + "\n";
|
#if FLIPPER_DEBUG_LOG
|
||||||
|
log("[failed] " + step);
|
||||||
|
#endif
|
||||||
|
logs = logs + "[Failed] " + step + ": " + errorMessage + "\n";
|
||||||
stateMap[step] = State::failed;
|
stateMap[step] = State::failed;
|
||||||
if (mListener) {
|
if (mListener) {
|
||||||
mListener->onUpdate();
|
mListener->onUpdate();
|
||||||
@@ -52,7 +64,7 @@ void FlipperState::failed(std::string step, std::string errorMessage) {
|
|||||||
// representation of the current state so the UI can show it in a more intuitive
|
// representation of the current state so the UI can show it in a more intuitive
|
||||||
// way
|
// way
|
||||||
std::string FlipperState::getState() {
|
std::string FlipperState::getState() {
|
||||||
return log;
|
return logs;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<StateElement> FlipperState::getStateElements() {
|
std::vector<StateElement> FlipperState::getStateElements() {
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ class FlipperState {
|
|||||||
void started(std::string);
|
void started(std::string);
|
||||||
|
|
||||||
std::shared_ptr<FlipperStateUpdateListener> mListener = nullptr;
|
std::shared_ptr<FlipperStateUpdateListener> mListener = nullptr;
|
||||||
std::string log;
|
std::string logs;
|
||||||
std::vector<std::string> insertOrder;
|
std::vector<std::string> insertOrder;
|
||||||
std::map<std::string, facebook::flipper::State> stateMap;
|
std::map<std::string, facebook::flipper::State> stateMap;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user