From 867ea1bfaf7f409f905889179de90c7e21e08ad2 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Fri, 11 Nov 2016 08:08:28 -0800 Subject: [PATCH] Expose CSSLayoutSetLogger to java Reviewed By: astreet Differential Revision: D4153502 fbshipit-source-id: 630909d9d0d36d94d7cd3027476ddb52668b8cc0 --- .../com/facebook/csslayout/CSSLogger.java | 27 +++++++++++++++++++ .../java/com/facebook/csslayout/CSSNode.java | 6 +++++ 2 files changed, 33 insertions(+) create mode 100644 ReactAndroid/src/main/java/com/facebook/csslayout/CSSLogger.java diff --git a/ReactAndroid/src/main/java/com/facebook/csslayout/CSSLogger.java b/ReactAndroid/src/main/java/com/facebook/csslayout/CSSLogger.java new file mode 100644 index 000000000..44536c46d --- /dev/null +++ b/ReactAndroid/src/main/java/com/facebook/csslayout/CSSLogger.java @@ -0,0 +1,27 @@ +/** + * Copyright (c) 2014-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +package com.facebook.csslayout; + +import com.facebook.proguard.annotations.DoNotStrip; + +/** + * Inteface for recieving logs from native layer. Use by setting CSSNode.setLogger(myLogger); + * LOG_LEVEL_ERROR indicated a fatal error. + */ +public interface CSSLogger { + public final int LOG_LEVEL_ERROR = 0; + public final int LOG_LEVEL_WARN = 1; + public final int LOG_LEVEL_INFO = 2; + public final int LOG_LEVEL_DEBUG = 3; + public final int LOG_LEVEL_VERBOSE = 4; + + @DoNotStrip + void log(int level, String message); +} diff --git a/ReactAndroid/src/main/java/com/facebook/csslayout/CSSNode.java b/ReactAndroid/src/main/java/com/facebook/csslayout/CSSNode.java index 612be2463..9cc47686b 100644 --- a/ReactAndroid/src/main/java/com/facebook/csslayout/CSSNode.java +++ b/ReactAndroid/src/main/java/com/facebook/csslayout/CSSNode.java @@ -33,6 +33,12 @@ public class CSSNode implements CSSNodeAPI { * Get native instance count. Useful for testing only. */ static native int jni_CSSNodeGetInstanceCount(); + static native void jni_CSSLog(int level, String message); + + private static native void jni_CSSLayoutSetLogger(Object logger); + public static void setLogger(CSSLogger logger) { + jni_CSSLayoutSetLogger(logger); + } private CSSNode mParent; private List mChildren;