LogChannel.h#
Fully qualified name: carb/logging/LogChannel.h
File members: carb/logging/LogChannel.h
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: LicenseRef-NvidiaProprietary
//
// NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
// property and proprietary rights in and to this material, related
// documentation and any modifications thereto. Any use, reproduction,
// disclosure or distribution of this material and related documentation
// without an express license agreement from NVIDIA CORPORATION or
// its affiliates is strictly prohibited.
#pragma once
#include <cstdint>
#define CARB_LOG_DECLARE_CHANNEL(varName) extern ::carb::logging::detail::LogChannelData varName
#define CARB_LOG_ADD_CHANNEL(varName, channelName, description) \
::carb::logging::detail::LogChannelData varName{ ("" channelName), 0, ("" description), nullptr }; \
static ::carb::logging::detail::LogChannelRegistrar varName##_Registrar(&(varName))
#ifndef CARB_LOG_DEFAULT_CHANNEL
# define CARB_LOG_DEFAULT_CHANNEL g_defaultLogChannel
#endif
namespace carb::logging::detail
{
struct LogChannelData
{
const char* const name;
int32_t level;
const char* const description;
LogChannelData* next;
};
struct DefaultLogChannelData : public LogChannelData
{
DefaultLogChannelData() : LogChannelData{ "<default>", 0, "Default log channel", nullptr }
{
}
};
inline LogChannelData*& logChannelHead() noexcept
{
static LogChannelData* head = nullptr;
return head;
}
inline bool& logChannelsRegistered() noexcept
{
static bool registered{ false };
return registered;
}
} // namespace carb::logging::detail