mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Enable Yoga logging in Fabric Debug
Summary: This diff extends Fabric to support Yoga logging changeLog: [Internal] Internal changes in Fabric to enable yoga logging Reviewed By: JoshuaGross Differential Revision: D21150195 fbshipit-source-id: a2e8308a79a7b422bf9ecc3a65f822b305f02c5d
This commit is contained in:
committed by
Facebook GitHub Bot
parent
1fdb9ac69c
commit
8c4efc94e1
@@ -6,11 +6,6 @@
|
||||
*/
|
||||
|
||||
#include "YogaLayoutableShadowNode.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
|
||||
#include <react/components/view/ViewProps.h>
|
||||
#include <react/components/view/conversions.h>
|
||||
#include <react/core/LayoutConstraints.h>
|
||||
@@ -18,6 +13,9 @@
|
||||
#include <react/debug/DebugStringConvertibleItem.h>
|
||||
#include <react/debug/SystraceSection.h>
|
||||
#include <yoga/Yoga.h>
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
@@ -396,10 +394,29 @@ YGSize YogaLayoutableShadowNode::yogaNodeMeasureCallbackConnector(
|
||||
yogaFloatFromFloat(size.height)};
|
||||
}
|
||||
|
||||
#ifdef RN_DEBUG_YOGA_LOGGER
|
||||
static int YogaLog(
|
||||
const YGConfigRef config,
|
||||
const YGNodeRef node,
|
||||
YGLogLevel level,
|
||||
const char *format,
|
||||
va_list args) {
|
||||
int result = vsnprintf(NULL, 0, format, args);
|
||||
std::vector<char> buffer(1 + result);
|
||||
vsnprintf(buffer.data(), buffer.size(), format, args);
|
||||
LOG(INFO) << "RNYogaLogger " << buffer.data();
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
YGConfig &YogaLayoutableShadowNode::initializeYogaConfig(YGConfig &config) {
|
||||
config.setCloneNodeCallback(
|
||||
YogaLayoutableShadowNode::yogaNodeCloneCallbackConnector);
|
||||
config.useLegacyStretchBehaviour = true;
|
||||
#ifdef RN_DEBUG_YOGA_LOGGER
|
||||
config.printTree = true;
|
||||
config.setLogger(&YogaLog);
|
||||
#endif
|
||||
return config;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,12 @@ namespace react {
|
||||
#define RN_DEBUG_STRING_CONVERTIBLE 1
|
||||
#endif
|
||||
|
||||
// To Debug Yoga layout, uncomment the following line.
|
||||
// #define RN_DEBUG_YOGA_LOGGER 1
|
||||
//
|
||||
// Additional logging can be enabled editing yoga.cpp (e.g. gPrintChanges,
|
||||
// gPrintSkips)
|
||||
|
||||
#if RN_DEBUG_STRING_CONVERTIBLE
|
||||
|
||||
class DebugStringConvertible;
|
||||
|
||||
Reference in New Issue
Block a user