Add support for context-aware logging functions

Summary:
@public

Context-aware logging functions are an internal Yoga feature that will be used for Yoga’s JNI code.

It will be possible to specify a context when calculating layout, which will be passed on to baseline and measure functions. This will be a private feature.

Reviewed By: SidharthGuglani

Differential Revision: D14123482

fbshipit-source-id: 8ba3b6c493bf79fe09831f22d2b6da44f09e3d95
This commit is contained in:
David Aurelio
2019-02-19 09:54:45 -08:00
committed by Facebook Github Bot
parent 0bdf36f5d1
commit d5ad51bccc
6 changed files with 60 additions and 13 deletions

View File

@@ -6,13 +6,21 @@
*/
#include "YGConfig.h"
YGConfig::YGConfig(YGLogger logger) : logger_{logger} {}
YGConfig::YGConfig(YGLogger logger) {
logger_.noContext = logger;
loggerUsesContext_ = false;
}
void YGConfig::log(
YGConfig* config,
YGNode* node,
YGLogLevel logLevel,
void* logContext,
const char* format,
va_list args) {
logger_(config, node, logLevel, format, args);
if (loggerUsesContext_) {
logger_.withContext(config, node, logLevel, logContext, format, args);
} else {
logger_.noContext(config, node, logLevel, format, args);
}
}