- HandlerMinelayerData: BUILD_RTI Guards für RTI-Abhängigkeiten - svcTabCommon: Export-Header-Fix via Fallback-Target - TrainingAreaBase: Stub-Header für BUILD_RTI=OFF - ddsfts: Include-Pfad und Dependency-Fixes - BUILD_RTI=OFF Compilation vollständig unterstützt Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Entire-Checkpoint: 01M0JNZA586SACX1PRZ2DJAE5S
224 lines
5.5 KiB
C++
224 lines
5.5 KiB
C++
/**
|
|
* (c) Copyright, Real-Time Innovations, 2020. All rights reserved.
|
|
*
|
|
* No duplications, whole or partial, manual or electronic, may be made
|
|
* without express written permission. Any such copies, or
|
|
* revisions thereof, must display this notice unaltered.
|
|
* This code contains trade secrets of Real-Time Innovations, Inc.
|
|
*/
|
|
|
|
#ifndef RTI_CDS_LOGGER_HPP_
|
|
#define RTI_CDS_LOGGER_HPP_
|
|
|
|
#include <dds/core/Reference.hpp>
|
|
#include <rti/config/Logger.hpp>
|
|
|
|
#include "clouddiscoveryservice/clouddiscoveryservice_service.h"
|
|
#include "clouddiscoveryservice/clouddiscoveryservice_log.h"
|
|
|
|
namespace rti { namespace cds {
|
|
|
|
/** \defgroup RTI_CDS_Logger Logging
|
|
*
|
|
* @brief Provides control over the logging facilities for @product.
|
|
*/
|
|
|
|
/** \ingroup RTI_CDS_Logger
|
|
*
|
|
* @brief The singleton type used to configure @product verbosity
|
|
*
|
|
* For configuring other aspects such as output file, print format or
|
|
* RTI Connext specific logging, use rti::config::Logger.
|
|
*/
|
|
class Logger
|
|
{
|
|
public:
|
|
|
|
typedef rti::config::Verbosity Verbosity;
|
|
typedef rti::config::LogCategory LogCategory;
|
|
typedef rti::config::PrintFormat PrintFormat;
|
|
|
|
static Logger& instance()
|
|
{
|
|
static Logger singleton;
|
|
return singleton;
|
|
}
|
|
|
|
/**
|
|
* @brief Sets the verbosity for the log messages generated at the
|
|
* @product level.
|
|
*
|
|
* @param verbosity
|
|
* @rs_st_in The verbosity of the service logs
|
|
*/
|
|
void service_verbosity(rti::config::Verbosity verbosity)
|
|
{
|
|
NDDS_Config_Logger_set_verbosity_by_service(
|
|
NDDS_Config_Logger_get_instance(),
|
|
NDDS_CONFIG_LOG_SERVICE_CLOUD_DISCOVERY,
|
|
static_cast<NDDS_Config_LogVerbosity>(verbosity.underlying()));
|
|
}
|
|
|
|
/**
|
|
* @brief Getter for the same attribute
|
|
*
|
|
* @see service_verbosity(rti::config::Verbosity)
|
|
*/
|
|
rti::config::Verbosity service_verbosity()
|
|
{
|
|
RTILogBitmap instrumentation_mask =
|
|
NDDS_Config_Logger_get_verbosity_by_service(
|
|
NDDS_Config_Logger_get_instance(),
|
|
NDDS_CONFIG_LOG_SERVICE_CLOUD_DISCOVERY);
|
|
|
|
return static_cast<rti::config::Verbosity::type>(instrumentation_mask);
|
|
}
|
|
|
|
/**
|
|
* @brief Logs a message with EXCEPTION level
|
|
*
|
|
* The generated log will be part of logging stream of the running service
|
|
* if the service verbosity contains EXCEPTION messages. The result log
|
|
* message may include additional information according to the
|
|
* Connext logging configuration, such as Advlog Context, thread ID,
|
|
* line number, etc. Additionally, the result log message will contain a
|
|
* newline character at the end, so the format does not need to contain it.
|
|
*
|
|
* @param [in] msg Message to be logged
|
|
*/
|
|
void error(const std::string& msg)
|
|
{
|
|
this->error(msg.c_str());
|
|
}
|
|
|
|
/**
|
|
* @brief Overload of error(const std::string& msg)
|
|
*/
|
|
void error(const char *msg)
|
|
{
|
|
this->message(rti::config::LogLevel::EXCEPTION, msg);
|
|
}
|
|
|
|
/**
|
|
* @brief Logs as message with WARNING level
|
|
*
|
|
* This operation behaves similar to error() except the log level is
|
|
* WARNING.
|
|
*
|
|
* @param [in] msg Message to be logged
|
|
*
|
|
* @see rti::cds::Logger::error
|
|
*
|
|
*/
|
|
void warn(const std::string& msg)
|
|
{
|
|
this->warn(msg.c_str());
|
|
}
|
|
|
|
/**
|
|
* @brief Overload of warn(const std::string& msg)
|
|
*/
|
|
void warn(const char *msg)
|
|
{
|
|
this->message(rti::config::LogLevel::WARNING, msg);
|
|
}
|
|
|
|
/**
|
|
* @brief Logs as message with WARNING level
|
|
*
|
|
* This operation behaves similar to error() except the log level is
|
|
* STATUS_LOCAL.
|
|
*
|
|
* @param [in] msg Message to be logged
|
|
*
|
|
* @see rti::cds::Logger::error
|
|
*
|
|
*/
|
|
void local(const std::string& msg)
|
|
{
|
|
this->local(msg.c_str());
|
|
}
|
|
|
|
/**
|
|
* @brief Overload of local(const std::string& msg)
|
|
*/
|
|
void local(const char *msg)
|
|
{
|
|
this->message(rti::config::LogLevel::STATUS_LOCAL, msg);
|
|
}
|
|
|
|
/**
|
|
* @brief Logs a message with WARNING level
|
|
*
|
|
* This operation behaves similar to error() except the log level is
|
|
* STATUS_REMOTE.
|
|
*
|
|
* @param [in] msg Message to be logged
|
|
*
|
|
* @see rti::cds::Logger::error
|
|
*
|
|
*/
|
|
void remote(const std::string& msg)
|
|
{
|
|
this->remote(msg.c_str());
|
|
}
|
|
|
|
/**
|
|
* @brief Overload of remote(const std::string& msg)
|
|
*/
|
|
void remote(const char *msg)
|
|
{
|
|
this->message(rti::config::LogLevel::STATUS_REMOTE, msg);
|
|
}
|
|
|
|
/**
|
|
* @brief Logs as message with WARNING level
|
|
*
|
|
* This operation behaves similar to error() except the log level is
|
|
* STATUS_DEBUG.
|
|
*
|
|
* @param [in] msg Message to be logged
|
|
*
|
|
* @see rti::cds::Logger::error
|
|
*
|
|
*/
|
|
void debug(const std::string& msg)
|
|
{
|
|
this->debug(msg.c_str());
|
|
}
|
|
|
|
/**
|
|
* @brief Overload of debug(const std::string& msg)
|
|
*/
|
|
void debug(const char *msg)
|
|
{
|
|
this->message(rti::config::LogLevel::STATUS_ALL, msg);
|
|
}
|
|
|
|
virtual ~Logger()
|
|
{
|
|
}
|
|
|
|
private:
|
|
|
|
void message(const rti::config::LogLevel& level, const char* msg)
|
|
{
|
|
RTI_CDS_Logger_log(
|
|
static_cast<NDDS_Config_LogLevel>(level.underlying()),
|
|
"%s",
|
|
msg);
|
|
}
|
|
|
|
Logger()
|
|
{
|
|
}
|
|
|
|
// Disable copy
|
|
Logger(const Logger&);
|
|
Logger& operator=(const Logger&);
|
|
};
|
|
|
|
}}
|
|
|
|
#endif // RTI_CDS_LOGGER_HPP_
|