Move YGLogger into YGConfig and associate YGNodeRef with log events

Summary:
Moves the `YGLogger` into `YGConfig` and pass the `YGNodeRef` into the logger to be able to associate the log messages and assertions with the specific node.

Tackles facebook/yoga#530 and facebook/yoga#446
Closes https://github.com/facebook/yoga/pull/531

Reviewed By: astreet

Differential Revision: D4970149

Pulled By: emilsjolander

fbshipit-source-id: b7fcdaa273143ea2fa35861620b2e4d79f04f0af
This commit is contained in:
Lukas Wöhrl
2017-05-03 09:22:35 -07:00
committed by Facebook Github Bot
parent 40eba60cf5
commit 91230ae177
36 changed files with 863 additions and 606 deletions

View File

@@ -20,6 +20,7 @@ public class YogaConfig {
}
long mNativePointer;
private YogaLogger mLogger;
private native long jni_YGConfigNew();
public YogaConfig() {
@@ -67,4 +68,14 @@ public class YogaConfig {
public void setUseLegacyStretchBehaviour(boolean useLegacyStretchBehaviour) {
jni_YGConfigSetUseLegacyStretchBehaviour(mNativePointer, useLegacyStretchBehaviour);
}
private native void jni_YGConfigSetLogger(long nativePointer, Object logger);
public void setLogger(YogaLogger logger) {
mLogger = logger;
jni_YGConfigSetLogger(mNativePointer, logger);
}
public YogaLogger getLogger() {
return mLogger;
}
}

View File

@@ -17,7 +17,8 @@ public enum YogaLogLevel {
WARN(1),
INFO(2),
DEBUG(3),
VERBOSE(4);
VERBOSE(4),
FATAL(5);
private int mIntValue;
@@ -36,6 +37,7 @@ public enum YogaLogLevel {
case 2: return INFO;
case 3: return DEBUG;
case 4: return VERBOSE;
case 5: return FATAL;
default: throw new IllegalArgumentException("Unknown enum value: " + value);
}
}

View File

@@ -18,5 +18,5 @@ import com.facebook.proguard.annotations.DoNotStrip;
@DoNotStrip
public interface YogaLogger {
@DoNotStrip
void log(YogaLogLevel level, String message);
void log(YogaNode node, YogaLogLevel level, String message);
}

View File

@@ -28,12 +28,6 @@ public class YogaNode {
* Get native instance count. Useful for testing only.
*/
static native int jni_YGNodeGetInstanceCount();
static native void jni_YGLog(int level, String message);
private static native void jni_YGSetLogger(Object logger);
public static void setLogger(YogaLogger logger) {
jni_YGSetLogger(logger);
}
private YogaNode mParent;
private List<YogaNode> mChildren;