LogChannel.h#

Fully qualified name: omni/log/LogChannel.h

File members: omni/log/LogChannel.h

// SPDX-FileCopyrightText: Copyright (c) 2020-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 "../../carb/logging/LogChannel.h"

#include <cstdint>
#include <vector>

#define OMNI_LOG_DECLARE_CHANNEL(varName_) extern ::omni::log::LogChannelData varName_;

#define OMNI_LOG_ADD_CHANNEL(varName_, channelName_, description_)                                                     \
    OMNI_LOG_DEFINE_CHANNEL(varName_, channelName_, description_);                                                     \
    static ::omni::log::LogChannelRegistrar varName_##Registrar{ &varName_ };

#define OMNI_LOG_DEFINE_CHANNEL(varName_, channelName_, description_)                                                  \
    ::omni::log::LogChannelData varName_{ channelName_, 0 /*kLevelWarn*/, description_, nullptr };

#ifndef OMNI_LOG_DEFAULT_CHANNEL

#    define OMNI_LOG_DEFAULT_CHANNEL kDefaultChannel

#endif

namespace omni::log
{

using LogChannelData = ::carb::logging::detail::LogChannelData;

inline LogChannelData*& getModuleLogChannels() noexcept
{
    return ::carb::logging::detail::logChannelHead();
}

inline bool& hasModuleLogChannelsRegistered() noexcept
{
    return ::carb::logging::detail::logChannelsRegistered();
}

} // namespace omni::log

#ifndef DOXYGEN_BUILD

#    define OMNI_LOG_DECLARE_DEFAULT_CHANNEL_1(chan_) OMNI_LOG_DECLARE_CHANNEL(chan_)
#    define OMNI_LOG_DECLARE_DEFAULT_CHANNEL() OMNI_LOG_DECLARE_DEFAULT_CHANNEL_1(OMNI_LOG_DEFAULT_CHANNEL)

// forward declare the default channel
OMNI_LOG_DECLARE_DEFAULT_CHANNEL()

#endif