C++ style enums 5/N: LogLevel (#1387)
Summary: Pull Request resolved: https://github.com/facebook/yoga/pull/1387 X-link: https://github.com/facebook/react-native/pull/39447 This converts usages of YGLogLevel to LogLevel Reviewed By: rozele Differential Revision: D49270695 fbshipit-source-id: 2ba5b4f2b0af93fef89dbbb2ce54c2f486670aac
This commit is contained in:
committed by
Facebook GitHub Bot
parent
6f5eaefc51
commit
70954bbda5
@@ -805,7 +805,7 @@ void YGNodePrint(const YGNodeConstRef nodeRef, const YGPrintOptions options) {
|
|||||||
const auto node = resolveRef(nodeRef);
|
const auto node = resolveRef(nodeRef);
|
||||||
std::string str;
|
std::string str;
|
||||||
yoga::nodeToString(str, node, options, 0);
|
yoga::nodeToString(str, node, options, 0);
|
||||||
yoga::log(node, YGLogLevelDebug, str.c_str());
|
yoga::log(node, LogLevel::Debug, str.c_str());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -2526,14 +2526,14 @@ bool calculateLayoutInternal(
|
|||||||
if (gPrintChanges && gPrintSkips) {
|
if (gPrintChanges && gPrintSkips) {
|
||||||
yoga::log(
|
yoga::log(
|
||||||
node,
|
node,
|
||||||
YGLogLevelVerbose,
|
LogLevel::Verbose,
|
||||||
"%s%d.{[skipped] ",
|
"%s%d.{[skipped] ",
|
||||||
spacerWithLength(depth),
|
spacerWithLength(depth),
|
||||||
depth);
|
depth);
|
||||||
node->print();
|
node->print();
|
||||||
yoga::log(
|
yoga::log(
|
||||||
node,
|
node,
|
||||||
YGLogLevelVerbose,
|
LogLevel::Verbose,
|
||||||
"wm: %s, hm: %s, aw: %f ah: %f => d: (%f, %f) %s\n",
|
"wm: %s, hm: %s, aw: %f ah: %f => d: (%f, %f) %s\n",
|
||||||
measureModeName(widthMeasureMode, performLayout),
|
measureModeName(widthMeasureMode, performLayout),
|
||||||
measureModeName(heightMeasureMode, performLayout),
|
measureModeName(heightMeasureMode, performLayout),
|
||||||
@@ -2547,7 +2547,7 @@ bool calculateLayoutInternal(
|
|||||||
if (gPrintChanges) {
|
if (gPrintChanges) {
|
||||||
yoga::log(
|
yoga::log(
|
||||||
node,
|
node,
|
||||||
YGLogLevelVerbose,
|
LogLevel::Verbose,
|
||||||
"%s%d.{%s",
|
"%s%d.{%s",
|
||||||
spacerWithLength(depth),
|
spacerWithLength(depth),
|
||||||
depth,
|
depth,
|
||||||
@@ -2555,7 +2555,7 @@ bool calculateLayoutInternal(
|
|||||||
node->print();
|
node->print();
|
||||||
yoga::log(
|
yoga::log(
|
||||||
node,
|
node,
|
||||||
YGLogLevelVerbose,
|
LogLevel::Verbose,
|
||||||
"wm: %s, hm: %s, aw: %f ah: %f %s\n",
|
"wm: %s, hm: %s, aw: %f ah: %f %s\n",
|
||||||
measureModeName(widthMeasureMode, performLayout),
|
measureModeName(widthMeasureMode, performLayout),
|
||||||
measureModeName(heightMeasureMode, performLayout),
|
measureModeName(heightMeasureMode, performLayout),
|
||||||
@@ -2582,7 +2582,7 @@ bool calculateLayoutInternal(
|
|||||||
if (gPrintChanges) {
|
if (gPrintChanges) {
|
||||||
yoga::log(
|
yoga::log(
|
||||||
node,
|
node,
|
||||||
YGLogLevelVerbose,
|
LogLevel::Verbose,
|
||||||
"%s%d.}%s",
|
"%s%d.}%s",
|
||||||
spacerWithLength(depth),
|
spacerWithLength(depth),
|
||||||
depth,
|
depth,
|
||||||
@@ -2590,7 +2590,7 @@ bool calculateLayoutInternal(
|
|||||||
node->print();
|
node->print();
|
||||||
yoga::log(
|
yoga::log(
|
||||||
node,
|
node,
|
||||||
YGLogLevelVerbose,
|
LogLevel::Verbose,
|
||||||
"wm: %s, hm: %s, d: (%f, %f) %s\n",
|
"wm: %s, hm: %s, d: (%f, %f) %s\n",
|
||||||
measureModeName(widthMeasureMode, performLayout),
|
measureModeName(widthMeasureMode, performLayout),
|
||||||
measureModeName(heightMeasureMode, performLayout),
|
measureModeName(heightMeasureMode, performLayout),
|
||||||
@@ -2609,7 +2609,7 @@ bool calculateLayoutInternal(
|
|||||||
if (layout->nextCachedMeasurementsIndex ==
|
if (layout->nextCachedMeasurementsIndex ==
|
||||||
LayoutResults::MaxCachedMeasurements) {
|
LayoutResults::MaxCachedMeasurements) {
|
||||||
if (gPrintChanges) {
|
if (gPrintChanges) {
|
||||||
yoga::log(node, YGLogLevelVerbose, "Out of cache entries!\n");
|
yoga::log(node, LogLevel::Verbose, "Out of cache entries!\n");
|
||||||
}
|
}
|
||||||
layout->nextCachedMeasurementsIndex = 0;
|
layout->nextCachedMeasurementsIndex = 0;
|
||||||
}
|
}
|
||||||
|
@@ -96,10 +96,10 @@ void Config::setLogger(YGLogger logger) {
|
|||||||
|
|
||||||
void Config::log(
|
void Config::log(
|
||||||
const yoga::Node* node,
|
const yoga::Node* node,
|
||||||
YGLogLevel logLevel,
|
LogLevel logLevel,
|
||||||
const char* format,
|
const char* format,
|
||||||
va_list args) const {
|
va_list args) const {
|
||||||
logger_(this, node, logLevel, format, args);
|
logger_(this, node, unscopedEnum(logLevel), format, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Config::setCloneNodeCallback(YGCloneNodeFunc cloneNode) {
|
void Config::setCloneNodeCallback(YGCloneNodeFunc cloneNode) {
|
||||||
|
@@ -12,6 +12,7 @@
|
|||||||
#include <yoga/Yoga.h>
|
#include <yoga/Yoga.h>
|
||||||
#include <yoga/enums/Errata.h>
|
#include <yoga/enums/Errata.h>
|
||||||
#include <yoga/enums/ExperimentalFeature.h>
|
#include <yoga/enums/ExperimentalFeature.h>
|
||||||
|
#include <yoga/enums/LogLevel.h>
|
||||||
|
|
||||||
// Tag struct used to form the opaque YGConfigRef for the public C API
|
// Tag struct used to form the opaque YGConfigRef for the public C API
|
||||||
struct YGConfig {};
|
struct YGConfig {};
|
||||||
@@ -67,7 +68,7 @@ class YG_EXPORT Config : public ::YGConfig {
|
|||||||
void setLogger(YGLogger logger);
|
void setLogger(YGLogger logger);
|
||||||
void log(
|
void log(
|
||||||
const yoga::Node* node,
|
const yoga::Node* node,
|
||||||
YGLogLevel logLevel,
|
LogLevel logLevel,
|
||||||
const char* format,
|
const char* format,
|
||||||
va_list args) const;
|
va_list args) const;
|
||||||
|
|
||||||
|
@@ -22,7 +22,7 @@ namespace facebook::yoga {
|
|||||||
|
|
||||||
void assertFatal(const bool condition, const char* message) {
|
void assertFatal(const bool condition, const char* message) {
|
||||||
if (!condition) {
|
if (!condition) {
|
||||||
yoga::log(YGLogLevelFatal, "%s\n", message);
|
yoga::log(LogLevel::Fatal, "%s\n", message);
|
||||||
fatalWithMessage(message);
|
fatalWithMessage(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -32,7 +32,7 @@ void assertFatalWithNode(
|
|||||||
const bool condition,
|
const bool condition,
|
||||||
const char* message) {
|
const char* message) {
|
||||||
if (!condition) {
|
if (!condition) {
|
||||||
yoga::log(node, YGLogLevelFatal, "%s\n", message);
|
yoga::log(node, LogLevel::Fatal, "%s\n", message);
|
||||||
fatalWithMessage(message);
|
fatalWithMessage(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -42,7 +42,7 @@ void assertFatalWithConfig(
|
|||||||
const bool condition,
|
const bool condition,
|
||||||
const char* message) {
|
const char* message) {
|
||||||
if (!condition) {
|
if (!condition) {
|
||||||
yoga::log(config, YGLogLevelFatal, "%s\n", message);
|
yoga::log(config, LogLevel::Fatal, "%s\n", message);
|
||||||
fatalWithMessage(message);
|
fatalWithMessage(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -18,18 +18,18 @@ namespace {
|
|||||||
void vlog(
|
void vlog(
|
||||||
const yoga::Config* config,
|
const yoga::Config* config,
|
||||||
const yoga::Node* node,
|
const yoga::Node* node,
|
||||||
YGLogLevel level,
|
LogLevel level,
|
||||||
const char* format,
|
const char* format,
|
||||||
va_list args) {
|
va_list args) {
|
||||||
if (config == nullptr) {
|
if (config == nullptr) {
|
||||||
getDefaultLogger()(nullptr, node, level, format, args);
|
getDefaultLogger()(nullptr, node, unscopedEnum(level), format, args);
|
||||||
} else {
|
} else {
|
||||||
config->log(node, level, format, args);
|
config->log(node, level, format, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void log(YGLogLevel level, const char* format, ...) noexcept {
|
void log(LogLevel level, const char* format, ...) noexcept {
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
vlog(nullptr, nullptr, level, format, args);
|
vlog(nullptr, nullptr, level, format, args);
|
||||||
@@ -38,7 +38,7 @@ void log(YGLogLevel level, const char* format, ...) noexcept {
|
|||||||
|
|
||||||
void log(
|
void log(
|
||||||
const yoga::Node* node,
|
const yoga::Node* node,
|
||||||
YGLogLevel level,
|
LogLevel level,
|
||||||
const char* format,
|
const char* format,
|
||||||
...) noexcept {
|
...) noexcept {
|
||||||
va_list args;
|
va_list args;
|
||||||
@@ -50,7 +50,7 @@ void log(
|
|||||||
|
|
||||||
void log(
|
void log(
|
||||||
const yoga::Config* config,
|
const yoga::Config* config,
|
||||||
YGLogLevel level,
|
LogLevel level,
|
||||||
const char* format,
|
const char* format,
|
||||||
...) noexcept {
|
...) noexcept {
|
||||||
va_list args;
|
va_list args;
|
||||||
|
@@ -9,23 +9,23 @@
|
|||||||
|
|
||||||
#include <yoga/Yoga.h>
|
#include <yoga/Yoga.h>
|
||||||
|
|
||||||
#include <yoga/YGEnums.h>
|
|
||||||
#include <yoga/config/Config.h>
|
#include <yoga/config/Config.h>
|
||||||
|
#include <yoga/enums/LogLevel.h>
|
||||||
#include <yoga/node/Node.h>
|
#include <yoga/node/Node.h>
|
||||||
|
|
||||||
namespace facebook::yoga {
|
namespace facebook::yoga {
|
||||||
|
|
||||||
void log(YGLogLevel level, const char* format, ...) noexcept;
|
void log(LogLevel level, const char* format, ...) noexcept;
|
||||||
|
|
||||||
void log(
|
void log(
|
||||||
const yoga::Node* node,
|
const yoga::Node* node,
|
||||||
YGLogLevel level,
|
LogLevel level,
|
||||||
const char* message,
|
const char* message,
|
||||||
...) noexcept;
|
...) noexcept;
|
||||||
|
|
||||||
void log(
|
void log(
|
||||||
const yoga::Config* config,
|
const yoga::Config* config,
|
||||||
YGLogLevel level,
|
LogLevel level,
|
||||||
const char* format,
|
const char* format,
|
||||||
...) noexcept;
|
...) noexcept;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user