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:
committed by
Facebook Github Bot
parent
0bdf36f5d1
commit
d5ad51bccc
@@ -10,8 +10,20 @@
|
||||
#include "Yoga.h"
|
||||
|
||||
struct YGConfig {
|
||||
using LogWithContextFn = void (*)(
|
||||
YGConfigRef config,
|
||||
YGNodeRef node,
|
||||
YGLogLevel level,
|
||||
void* context,
|
||||
const char* format,
|
||||
va_list args);
|
||||
|
||||
private:
|
||||
YGLogger logger_;
|
||||
union {
|
||||
LogWithContextFn withContext;
|
||||
YGLogger noContext;
|
||||
} logger_;
|
||||
bool loggerUsesContext_;
|
||||
|
||||
public:
|
||||
bool useWebDefaults = false;
|
||||
@@ -26,8 +38,16 @@ public:
|
||||
YGMarkerCallbacks markerCallbacks = {nullptr, nullptr};
|
||||
|
||||
YGConfig(YGLogger logger);
|
||||
void log(YGConfig*, YGNode*, YGLogLevel, const char*, va_list);
|
||||
void log(YGConfig*, YGNode*, YGLogLevel, void*, const char*, va_list);
|
||||
void setLogger(YGLogger logger) {
|
||||
logger_ = logger;
|
||||
logger_.noContext = logger;
|
||||
loggerUsesContext_ = false;
|
||||
}
|
||||
void setLogger(LogWithContextFn logger) {
|
||||
logger_.withContext = logger;
|
||||
loggerUsesContext_ = true;
|
||||
}
|
||||
void setLogger(std::nullptr_t) {
|
||||
setLogger(YGLogger{nullptr});
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user