FlipperState debug logs improvement
Summary: Make it more explicit. What has succeeded, failed, started. Reviewed By: ivanmisuno Differential Revision: D49227799 fbshipit-source-id: fe9e6baaff227cf1db0b3150a3ee8cf194d2b6e6
This commit is contained in:
committed by
Facebook GitHub Bot
parent
25e187bf41
commit
3605401e5e
@@ -9,13 +9,10 @@
|
||||
#include <vector>
|
||||
#include "FlipperStateUpdateListener.h"
|
||||
#include "FlipperStep.h"
|
||||
#include "Log.h"
|
||||
|
||||
#define FLIPPER_LOGS_CAPACITY 4096
|
||||
|
||||
#if FLIPPER_DEBUG_LOG
|
||||
#include "Log.h"
|
||||
#endif
|
||||
|
||||
using namespace facebook::flipper;
|
||||
|
||||
/* Class responsible for collecting state updates and combining them into a
|
||||
@@ -33,9 +30,9 @@ void FlipperState::started(std::string step) {
|
||||
std::shared_ptr<FlipperStateUpdateListener> localListener;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
#if FLIPPER_DEBUG_LOG
|
||||
log("[started] " + step);
|
||||
#endif
|
||||
|
||||
DEBUG_LOG("[step] [started] " + step);
|
||||
|
||||
if (stateMap.find(step) == stateMap.end()) {
|
||||
insertOrder.push_back(step);
|
||||
}
|
||||
@@ -53,7 +50,7 @@ void FlipperState::ensureLogsCapacity() {
|
||||
if (logs.tellp() > FLIPPER_LOGS_CAPACITY) {
|
||||
logs.str("");
|
||||
logs.clear();
|
||||
logs << "[Truncated]" << std::endl;
|
||||
logs << "[truncated]" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,10 +58,10 @@ void FlipperState::success(std::string step) {
|
||||
std::shared_ptr<FlipperStateUpdateListener> localListener;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
std::string message = "[Success] " + step;
|
||||
#if FLIPPER_DEBUG_LOG
|
||||
log(message);
|
||||
#endif
|
||||
std::string message = "[step] [success] " + step;
|
||||
|
||||
DEBUG_LOG(message);
|
||||
|
||||
ensureLogsCapacity();
|
||||
logs << message << std::endl;
|
||||
|
||||
@@ -82,10 +79,10 @@ void FlipperState::failed(std::string step, std::string errorMessage) {
|
||||
std::shared_ptr<FlipperStateUpdateListener> localListener;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
std::string message = "[Failed] " + step + ": " + errorMessage;
|
||||
#if FLIPPER_DEBUG_LOG
|
||||
log(message);
|
||||
#endif
|
||||
std::string message = "[step] [failed] " + step + ": " + errorMessage;
|
||||
|
||||
DEBUG_LOG(message);
|
||||
|
||||
ensureLogsCapacity();
|
||||
logs << message << std::endl;
|
||||
stateMap[step] = State::failed;
|
||||
@@ -98,7 +95,7 @@ void FlipperState::failed(std::string step, std::string errorMessage) {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Currently returns string, but should really provide a better
|
||||
// Currently returns string, but should really provide a better
|
||||
// representation of the current state so the UI can show it in a more intuitive
|
||||
// way
|
||||
std::string FlipperState::getState() {
|
||||
|
||||
@@ -22,3 +22,9 @@ void defaultLogHandler(const std::string& message);
|
||||
|
||||
} // namespace flipper
|
||||
} // namespace facebook
|
||||
|
||||
#if FLIPPER_DEBUG_LOG
|
||||
#define DEBUG_LOG(...) facebook::flipper::log(__VA_ARGS__)
|
||||
#else
|
||||
#define DEBUG_LOG(...)
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user