From be88966ecb3a8721073cbf203e86362ef4209777 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Ag=C3=BCero?= Date: Mon, 19 Aug 2024 15:01:00 +0200 Subject: [PATCH] Namespaces MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Carlos Agüero --- log/include/CMakeLists.txt | 2 +- log/include/gz/utils/log/Logger.hh | 71 +++++++++++++++++------------- 2 files changed, 42 insertions(+), 31 deletions(-) diff --git a/log/include/CMakeLists.txt b/log/include/CMakeLists.txt index 87ba4cc..6645618 100644 --- a/log/include/CMakeLists.txt +++ b/log/include/CMakeLists.txt @@ -1 +1 @@ -add_subdirectory(gz/utils) \ No newline at end of file +add_subdirectory(gz/utils) diff --git a/log/include/gz/utils/log/Logger.hh b/log/include/gz/utils/log/Logger.hh index 47298cf..54e4958 100644 --- a/log/include/gz/utils/log/Logger.hh +++ b/log/include/gz/utils/log/Logger.hh @@ -20,38 +20,49 @@ #include #include #include +#include +#include #include -namespace gz::utils::log +namespace gz { - /// \brief Gazebo console and file logging class. - /// This will configure spdlog with a sane set of defaults for logging to the - /// console as well as a file. - class GZ_UTILS_VISIBLE Logger - { - /// \brief Class constructor. - /// \param[in] _loggerName Logger name. - public: explicit Logger(const std::string &_loggerName); - - /// \brief Set the log destination filename. - /// \param[in] _filename Log file name. - public: void SetLogDestination(const std::string &_filename); - - /// \brief Get the log destination filename. - /// \return Log file name. - public: std::string LogDestination() const; - - /// \brief Access the underlying spdlog logger. - /// \return The spdlog logger. - public: [[nodiscard]] spdlog::logger &RawLogger() const; - - /// \brief Access the underlying spdlog logger, with ownership. - /// \return The spdlog logger. - public: [[nodiscard]] std::shared_ptr RawLoggerPtr() const; - - /// \brief Implementation Pointer. - GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) - }; -} +namespace utils +{ +namespace log +{ +inline namespace GZ_UTILS_VERSION_NAMESPACE { + +/// \brief Gazebo console and file logging class. +/// This will configure spdlog with a sane set of defaults for logging to the +/// console as well as a file. +class GZ_UTILS_LOG_VISIBLE Logger +{ + /// \brief Class constructor. + /// \param[in] _loggerName Logger name. + public: explicit Logger(const std::string &_loggerName); + + /// \brief Set the log destination filename. + /// \param[in] _filename Log file name. + public: void SetLogDestination(const std::string &_filename); + + /// \brief Get the log destination filename. + /// \return Log file name. + public: std::string LogDestination() const; + + /// \brief Access the underlying spdlog logger. + /// \return The spdlog logger. + public: [[nodiscard]] spdlog::logger &RawLogger() const; + + /// \brief Access the underlying spdlog logger, with ownership. + /// \return The spdlog logger. + public: [[nodiscard]] std::shared_ptr RawLoggerPtr() const; + + /// \brief Implementation Pointer. + GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) +}; +} // namespace GZ_UTILS_VERSION_NAMESPACE +} // namespace log +} // namespace utils +} // namespace gz #endif // GZ_UTILS_LOG_LOGGER_HH_