| 1 | // Copyright (C) 2016 The Qt Company Ltd. |
| 2 | // Copyright (c) Meta Platforms, Inc. and affiliates. |
| 3 | // |
| 4 | // SPDX-License-Identifier: MIT |
| 5 | |
| 6 | #include <yoga/Yoga.h> |
| 7 | |
| 8 | #include "log.h" |
| 9 | #include "YGConfig.h" |
| 10 | #include "YGNode.h" |
| 11 | |
| 12 | QT_YOGA_NAMESPACE_BEGIN |
| 13 | |
| 14 | namespace facebook { |
| 15 | namespace yoga { |
| 16 | namespace detail { |
| 17 | |
| 18 | namespace { |
| 19 | |
| 20 | void vlog( |
| 21 | YGConfig* config, |
| 22 | YGNode* node, |
| 23 | YGLogLevel level, |
| 24 | void* context, |
| 25 | const char* format, |
| 26 | va_list args) { |
| 27 | YGConfig* logConfig = config != nullptr ? config : YGConfigGetDefault(); |
| 28 | logConfig->log(logConfig, node, level, context, format, args); |
| 29 | } |
| 30 | } // namespace |
| 31 | |
| 32 | YOGA_EXPORT void Log::log( |
| 33 | YGNode* node, |
| 34 | YGLogLevel level, |
| 35 | void* context, |
| 36 | const char* format, |
| 37 | ...) noexcept { |
| 38 | va_list args; |
| 39 | va_start(args, format); |
| 40 | vlog( |
| 41 | config: node == nullptr ? nullptr : node->getConfig(), |
| 42 | node, |
| 43 | level, |
| 44 | context, |
| 45 | format, |
| 46 | args); |
| 47 | va_end(args); |
| 48 | } |
| 49 | |
| 50 | void Log::log( |
| 51 | YGConfig* config, |
| 52 | YGLogLevel level, |
| 53 | void* context, |
| 54 | const char* format, |
| 55 | ...) noexcept { |
| 56 | va_list args; |
| 57 | va_start(args, format); |
| 58 | vlog(config, node: nullptr, level, context, format, args); |
| 59 | va_end(args); |
| 60 | } |
| 61 | |
| 62 | } // namespace detail |
| 63 | } // namespace yoga |
| 64 | } // namespace facebook |
| 65 | |
| 66 | QT_YOGA_NAMESPACE_END |
| 67 | |