Make logging private

Summary:
@public

Makes logging implementation internal to Yoga.

Breaking changes: removed  `YGLog` and `YGLogWithConfig`.

The upcoming changes to the JNI layer (removal of weak global refs for each node) requires adding additional parameters to the logging functions that will only be available when calculating layout.

Reviewed By: SidharthGuglani

Differential Revision: D14123390

fbshipit-source-id: 468e4a240c190342868ffbb5f8beb92324cdfdd6
This commit is contained in:
David Aurelio
2019-02-19 09:54:45 -08:00
committed by Facebook Github Bot
parent 446101a168
commit 1b9053bc5d
5 changed files with 113 additions and 58 deletions

60
yoga/log.cpp Normal file
View File

@@ -0,0 +1,60 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree.
*/
#include "log.h"
#include "Yoga.h"
#include "YGConfig.h"
#include "YGNode.h"
namespace facebook {
namespace yoga {
namespace detail {
namespace {
void vlog(
YGConfig* config,
YGNode* node,
YGLogLevel level,
const char* format,
va_list args) {
YGConfig* logConfig = config != nullptr ? config : YGConfigGetDefault();
logConfig->logger(logConfig, node, level, format, args);
if (level == YGLogLevelFatal) {
abort();
}
}
} // namespace
void Log::log(
YGNode* node,
YGLogLevel level,
const char* format,
...) noexcept {
va_list args;
va_start(args, format);
vlog(
node == nullptr ? nullptr : node->getConfig(), node, level, format, args);
va_end(args);
}
void Log::log(
YGConfig* config,
YGLogLevel level,
const char* format,
...) noexcept {
va_list args;
va_start(args, format);
vlog(config, nullptr, level, format, args);
va_end(args);
}
} // namespace detail
} // namespace yoga
} // namespace facebook