2016-10-19 11:01:24 -07:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2016-12-02 11:18:16 -08:00
|
|
|
#include "YGInterop.h"
|
2016-10-19 11:01:24 -07:00
|
|
|
|
2017-05-03 09:22:35 -07:00
|
|
|
static YGInteropLogger gManagedLogger;
|
2016-10-19 11:01:24 -07:00
|
|
|
|
2017-05-03 09:22:35 -07:00
|
|
|
static int unmanagedLogger(const YGConfigRef config,
|
|
|
|
const YGNodeRef node,
|
|
|
|
YGLogLevel level,
|
|
|
|
const char *format,
|
|
|
|
va_list args) {
|
2016-10-19 11:01:24 -07:00
|
|
|
int result = 0;
|
2017-05-03 09:22:35 -07:00
|
|
|
if (gManagedLogger) {
|
|
|
|
char message[8192];
|
|
|
|
result = vsnprintf(message, sizeof(message), format, args);
|
|
|
|
(*gManagedLogger)(config, node, level, message);
|
2016-10-19 11:01:24 -07:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2017-05-03 09:22:35 -07:00
|
|
|
void YGInteropSetLogger(YGInteropLogger managedLogger) {
|
|
|
|
gManagedLogger = managedLogger;
|
2017-05-04 09:12:34 -07:00
|
|
|
YGConfigSetLogger(YGConfigGetDefault(), &unmanagedLogger);
|
2016-10-19 11:01:24 -07:00
|
|
|
}
|