Skip to content

Commit

Permalink
Namespaces
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos Agüero <caguero@openrobotics.org>
  • Loading branch information
caguero committed Aug 19, 2024
1 parent 4cf0bcb commit be88966
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 31 deletions.
2 changes: 1 addition & 1 deletion log/include/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
add_subdirectory(gz/utils)
add_subdirectory(gz/utils)
71 changes: 41 additions & 30 deletions log/include/gz/utils/log/Logger.hh
Original file line number Diff line number Diff line change
Expand Up @@ -20,38 +20,49 @@
#include <spdlog/spdlog.h>
#include <memory>
#include <string>
#include <gz/utils/config.hh>
#include <gz/utils/Export.hh>
#include <gz/utils/ImplPtr.hh>

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<spdlog::logger> 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<spdlog::logger> 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_

0 comments on commit be88966

Please sign in to comment.