Update logging to support levels, print messages in Android logcat on assertion failures

Summary:
@public

The goal of this diff is to have assertion failures show up as error logs on Android. To do this, I updated the logging API to take calls with log levels. We now have to pass around va_list unfortunately since you can't re-expand or pass along var-args to a subcall.

Reviewed By: emilsjolander

Differential Revision: D4140898

fbshipit-source-id: e0eb9a1f0b08a7d90a8233f66bb857d5b871b6ad
This commit is contained in:
Andy Street
2016-11-09 09:45:37 -08:00
committed by Facebook Github Bot
parent 6a6efe0764
commit f1fcd5e382
3 changed files with 86 additions and 43 deletions

View File

@@ -115,6 +115,14 @@ typedef struct CSSSize {
float height;
} CSSSize;
typedef enum CSSLogLevel {
CSSLogLevelError,
CSSLogLevelWarn,
CSSLogLevelInfo,
CSSLogLevelDebug,
CSSLogLevelVerbose,
} CSSLogLevel;
typedef struct CSSNode *CSSNodeRef;
typedef CSSSize (*CSSMeasureFunc)(CSSNodeRef node,
float width,
@@ -122,7 +130,7 @@ typedef CSSSize (*CSSMeasureFunc)(CSSNodeRef node,
float height,
CSSMeasureMode heightMode);
typedef void (*CSSPrintFunc)(CSSNodeRef node);
typedef int (*CSSLogger)(const char *format, ...);
typedef int (*CSSLogger)(CSSLogLevel level, const char *format, va_list args);
#ifdef CSS_ASSERT_FAIL_ENABLED
typedef void (*CSSAssertFailFunc)(const char *message);
@@ -232,6 +240,7 @@ CSS_NODE_LAYOUT_PROPERTY(float, Height);
CSS_NODE_LAYOUT_PROPERTY(CSSDirection, Direction);
WIN_EXPORT void CSSLayoutSetLogger(CSSLogger logger);
WIN_EXPORT void CSSLog(CSSLogLevel level, const char *message, ...);
#ifdef CSS_ASSERT_FAIL_ENABLED
// Assert