Introduce CSSLayoutSetLogger to pass the print result to C# side
Summary: - CSSLayoutSetLogger - Problem: Unity or other logging system can't use printf output - Solution: Add CSSLogger to pass CSSNodePrint result to UnityEngine.Debug.Log or other logging system via CSSLogger function for debugging purpose Reviewed By: emilsjolander Differential Revision: D4027044 fbshipit-source-id: 90e2e449260888770f71fa7ea790ca9764d91c44
This commit is contained in:
committed by
Facebook Github Bot
parent
e4ad7d3c12
commit
daed6f5b8a
30
csharp/CSSLayout/CSSInterop.cpp
Normal file
30
csharp/CSSLayout/CSSInterop.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "CSSInterop.h"
|
||||
|
||||
static CSSInteropLoggerFunc gManagedFunc;
|
||||
|
||||
static int unmanagedLogger(const char *format, ...) {
|
||||
int result = 0;
|
||||
if (gManagedFunc) {
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
char buffer[256];
|
||||
result = vsnprintf(buffer, sizeof(buffer), format, args);
|
||||
(*gManagedFunc)(buffer);
|
||||
va_end(args);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void CSSInteropSetLogger(CSSInteropLoggerFunc managedFunc) {
|
||||
gManagedFunc = managedFunc;
|
||||
CSSLayoutSetLogger(&unmanagedLogger);
|
||||
}
|
Reference in New Issue
Block a user