From 3f819f7ab70a393eab70c8e6f621d843847331f8 Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Tue, 27 Aug 2024 17:40:10 -0700 Subject: [PATCH 01/10] Update Changelog, README and prepare for gz-common6.0.0~pre1 release (#626) Signed-off-by: Ian Chen --- CMakeLists.txt | 2 +- Changelog.md | 106 ++++++++++++++++++++++++++++++++++++++++++++++++- README.md | 10 ++--- 3 files changed, 111 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 745deacc..3804066b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,7 @@ set(GZ_CMAKE_VER ${gz-cmake4_VERSION_MAJOR}) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) -gz_configure_project(VERSION_SUFFIX) +gz_configure_project(VERSION_SUFFIX pre1) #============================================================================ # Set project-specific options diff --git a/Changelog.md b/Changelog.md index 7e9ef3d0..e5cb87a0 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,6 +1,110 @@ ## Gazebo Common 6.x -## Gazebo Common 6.0.0 (20XX-XX-XX) +## Gazebo Common 6.0.0 (2024-09-XX) + +1. **Baseline:** this includes all changes from 5.6.0 and earlier. + +1. Use self-pipe trick to implement signal handlers + * [Pull request #618](https://github.com/gazebosim/gz-common/pull/618) + +1. Replace GTS with CDT + * [Pull request #617](https://github.com/gazebosim/gz-common/pull/617) + +1. Remove debug logging introduced accidentally in PR review + * [Pull request #622](https://github.com/gazebosim/gz-common/pull/622) + +1. Fix crash when calling absPath with empty input + * [Pull request #620](https://github.com/gazebosim/gz-common/pull/620) + +1. DEM: Add support for GDAL vsicurl, vsizip support and avoid segfaults with huge VRT datasets + * [Pull request #597](https://github.com/gazebosim/gz-common/pull/597) + +1. Enable 24.04 CI, require cmake 3.22.1 + * [Pull request #619](https://github.com/gazebosim/gz-common/pull/619) + +1. SubMesh::RecalculateNormals improvement + * [Pull request #609](https://github.com/gazebosim/gz-common/pull/609) + +1. fix data race tsan issue + * [Pull request #612](https://github.com/gazebosim/gz-common/pull/612) + +1. Generate a more unique texture name for glb embedded textures + * [Pull request #606](https://github.com/gazebosim/gz-common/pull/606) + +1. Add package.xml + * [Pull request #587](https://github.com/gazebosim/gz-common/pull/587) + +1. Fix deprecation warnings + * [Pull request #603](https://github.com/gazebosim/gz-common/pull/603) + +1. Fix macOS workflow and update on-push branches + * [Pull request #602](https://github.com/gazebosim/gz-common/pull/602) + +1. port: 5 to main + * [Pull request #594](https://github.com/gazebosim/gz-common/pull/594) + +1. Clean up Clang compiler warnings + * [Pull request #589](https://github.com/gazebosim/gz-common/pull/589) + +1. Add new function in MeshManager to merge all submeshes of a mesh into one + * [Pull request #588](https://github.com/gazebosim/gz-common/pull/588) + +1. Adds new function in MeshManager for performing convex decomposition + * [Pull request #585](https://github.com/gazebosim/gz-common/pull/585) + +1. Fix compatibility with FFmpeg5.0 + * [Pull request #581](https://github.com/gazebosim/gz-common/pull/581) + +1. Remove HIDE_SYMBOLS_BY_DEFAULT: replace by a default configuration in gz-cmake. + * [Pull request #568](https://github.com/gazebosim/gz-common/pull/568) + +1. Fix search for UUID on Windows logic + * [Pull request #556](https://github.com/gazebosim/gz-common/pull/556) + +1. Fix windows compilation by setting right visibility attributes + * [Pull request #550](https://github.com/gazebosim/gz-common/pull/550) + +1. Drop the internal vendored version of TinyXML2 + * [Pull request #542](https://github.com/gazebosim/gz-common/pull/542) + +1. Revert "Add missing visibility declarations (#548)" + * [Pull request #553](https://github.com/gazebosim/gz-common/pull/553) + +1. Add missing visibility declarations + * [Pull request #548](https://github.com/gazebosim/gz-common/pull/548) + +1. Remove ignition + * [Pull request #525](https://github.com/gazebosim/gz-common/pull/525) + +1. Bumps in ionic: use gz-cmake4, gz-utils3, gz-math8 + * [Pull request #539](https://github.com/gazebosim/gz-common/pull/539) + +1. Remove deprecated std::iterator inheritance + * [Pull request #529](https://github.com/gazebosim/gz-common/pull/529) + +1. Collada and Assimp test for default animation names + * [Pull request #476](https://github.com/gazebosim/gz-common/pull/476) + +1. Avoid Io.hh header name clash + * [Pull request #471](https://github.com/gazebosim/gz-common/pull/471) + +1. Default name assignment to animations without names + * [Pull request #413](https://github.com/gazebosim/gz-common/pull/413) + +1. Skip CSV header when reading DataFrame + * [Pull request #435](https://github.com/gazebosim/gz-common/pull/435) + +1. Main deprecations + * [Pull request #433](https://github.com/gazebosim/gz-common/pull/433) + +1. Add CSV data parsing + * [Pull request #402](https://github.com/gazebosim/gz-common/pull/402) + +1. Introduces Flips UV flag, removes empty space + * [Pull request #420](https://github.com/gazebosim/gz-common/pull/420) + +1. ⬆️ Bump main to 6.0.0~pre1 + * [Pull request #412](https://github.com/gazebosim/gz-common/pull/412) ## Gazebo Common 5.x diff --git a/README.md b/README.md index 628f501d..f2e02e2c 100644 --- a/README.md +++ b/README.md @@ -9,10 +9,10 @@ Build | Status -- | -- -Test coverage | [![codecov](https://codecov.io/gh/gazebosim/gz-common/tree/gz-common5/graph/badge.svg)](https://codecov.io/gh/gazebosim/gz-common/tree/gz-common5) -Ubuntu Jammy | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=gz_common-ci-gz-common5-jammy-amd64)](https://build.osrfoundation.org/job/gz_common-ci-gz-common5-jammy-amd64) -Homebrew | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=gz_common-ci-gz-common5-homebrew-amd64)](https://build.osrfoundation.org/job/gz_common-ci-gz-common5-homebrew-amd64) -Windows | [![Build Status](https://build.osrfoundation.org/job/gz_common-5-win/badge/icon)](https://build.osrfoundation.org/job/gz_common-5-win/) +Test coverage | [![codecov](https://codecov.io/gh/gazebosim/gz-common/tree/gz-common6/graph/badge.svg)](https://codecov.io/gh/gazebosim/gz-common/tree/gz-common6) +Ubuntu Noble | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=gz_common-ci-gz-common6-noble-amd64)](https://build.osrfoundation.org/job/gz_common-ci-gz-common6-noble-amd64) +Homebrew | [![Build Status](https://build.osrfoundation.org/buildStatus/icon?job=gz_common-ci-gz-common6-homebrew-amd64)](https://build.osrfoundation.org/job/gz_common-ci-gz-common6-homebrew-amd64) +Windows | [![Build Status](https://build.osrfoundation.org/job/gz_common-6-win/badge/icon)](https://build.osrfoundation.org/job/gz_common-6-win/) Gazebo Common, a component of [Gazebo](https://gazebosim.org), provides a set of libraries that cover many different use cases. An audio-visual library supports @@ -59,7 +59,7 @@ See the [installation tutorial](https://gazebosim.org/api/common/6/install.html) # Usage -Please refer to the [examples directory](https://github.com/gazebosim/gz-common/tree/main/examples). +Please refer to the [examples directory](https://github.com/gazebosim/gz-common/tree/gz-common6/examples). # Folder Structure From 8efac40b802cbd20b1d426d4c4e17e432050f529 Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Wed, 28 Aug 2024 18:50:55 -0500 Subject: [PATCH 02/10] Experimenting with spdlog (#615) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * spdlog logging integration. Signed-off-by: Michael Carroll Signed-off-by: Carlos Agüero Signed-off-by: Addisu Z. Taddese (cherry picked from commit 6cb5a53ec82a64108f99a50c77494e0a06d221ac) --- .github/ci/packages.apt | 2 + CMakeLists.txt | 2 +- Migration.md | 13 + examples/console.cc | 45 +++- include/gz/common/Console.hh | 291 ++++++++--------------- package.xml | 1 + src/CMakeLists.txt | 5 +- src/Console.cc | 365 +++++++---------------------- src/Console_TEST.cc | 28 ++- testing/src/AutoLogFixture_TEST.cc | 1 + 10 files changed, 252 insertions(+), 501 deletions(-) diff --git a/.github/ci/packages.apt b/.github/ci/packages.apt index cc24e491..e4b057bb 100644 --- a/.github/ci/packages.apt +++ b/.github/ci/packages.apt @@ -8,6 +8,8 @@ libgdal-dev libgz-cmake4-dev libgz-math8-dev libgz-utils3-dev +libgz-utils3-log-dev +libspdlog-dev libswscale-dev libtinyxml2-dev pkg-config diff --git a/CMakeLists.txt b/CMakeLists.txt index 3804066b..7288c884 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,7 +44,7 @@ set(GZ_MATH_VER ${gz-math8_VERSION_MAJOR}) #-------------------------------------- # Find gz-utils -gz_find_package(gz-utils3 REQUIRED) +gz_find_package(gz-utils3 REQUIRED COMPONENTS log) set(GZ_UTILS_VER ${gz-utils3_VERSION_MAJOR}) #-------------------------------------- diff --git a/Migration.md b/Migration.md index c93cf309..df92bb7d 100644 --- a/Migration.md +++ b/Migration.md @@ -9,6 +9,19 @@ release will remove the deprecated code. ### Modifications +1. Logging has been heavily modified as we're relying on + [spdlog](https://github.com/gabime/spdlog). See + [example1](https://github.com/gazebosim/gz-utils/blob/gz-utils3/examples/log/main.cc) + and [example2]((https://github.com/gazebosim/gz-common/blob/gz-common6/examples/console.cc)) + to learn how to access the internal spdlog logger and the global options. + + The `gzdbg`, `gzmsg`, `gzlog`, `gzwarn` and `gzerr` macros should work the + same as previous versions but you now have two extra macros: `gzcrit` and + `gztrace` for logging critical errors and traces respectively. + + `Console::SetVerbosity` only accepts values between 0 (critical errors only) + and 5 (all log messages). Other values don't have any effect. + 1. Removed the `graphics` component's dependency on the GTS (GNU Triangulated Surface) library which was used for doing triangulation and CSG Boolean operation by the `MeshManager`. The Delaunay triangulation diff --git a/examples/console.cc b/examples/console.cc index 0faf2659..f86e2e0a 100644 --- a/examples/console.cc +++ b/examples/console.cc @@ -14,22 +14,43 @@ * limitations under the License. * */ -#include +#include +#include int main(int argc, char **argv) { - // Default verbosity is 1, only error messages show - gzdbg << "This is a debug message" << std::endl; - gzmsg << "This is an informational message" << std::endl; - gzwarn << "This is a warning" << std::endl; - gzerr << "This is an error" << std::endl; + // Default verbosity is 3 (critical, error, warn and info messages show). + gztrace << "This is a trace message"; + gzdbg << "This is a debug message"; + gzmsg << "This is an informational message"; + gzwarn << "This is a warning"; + gzerr << "This is an error"; + gzcrit << "This is a critical error"; - // Change verbosity to level 4, all messages show - gz::common::Console::SetVerbosity(4); - gzdbg << "This is a debug message" << std::endl; - gzmsg << "This is an informational message" << std::endl; - gzwarn << "This is a warning" << std::endl; - gzerr << "This is an error" << std::endl; + // Change verbosity to level 5, all messages show. + gz::common::Console::SetVerbosity(5); + gz::common::Console::SetPrefix("My prefix. "); + gztrace << "This is a trace message"; + gzdbg << "This is a debug message"; + gzmsg << "This is an informational message"; + gzwarn << "This is a warning"; + gzerr << "This is an error"; + gzcrit << "This is a critical error"; + + std::filesystem::path logDir = std::filesystem::temp_directory_path(); + std::filesystem::path logFile = "my_log.txt"; + + gz::common::Console c("gz_tmp"); + c.SetLogDestination(logDir / "tmp2" / logFile); + auto logger = c.RawLogger(); + logger.log(spdlog::level::err, "Hello"); + + gz::common::Console::Init(logDir / "tmp3", logFile); + gzerr << "Error 1"; + gzerr << "Error 2"; + gzerr << "Directory: " << gz::common::Console::Directory(); + gz::common::Console::Close(); + gzerr << "Error 3"; return 0; } diff --git a/include/gz/common/Console.hh b/include/gz/common/Console.hh index 229880c2..a188de20 100644 --- a/include/gz/common/Console.hh +++ b/include/gz/common/Console.hh @@ -17,35 +17,79 @@ #ifndef GZ_COMMON_CONSOLE_HH_ #define GZ_COMMON_CONSOLE_HH_ -#include +#include +#include + #include -#include -#include +#include +#include #include #include #include -#include #include +#include +#include namespace gz { namespace common { - /// \brief Output an error message, if the verbose level is >= 1 - #define gzerr (gz::common::Console::err(__FILE__, __LINE__)) + /// \brief Helper class for providing gzlog macros. + class GZ_COMMON_VISIBLE LogMessage + { + /// \brief Constructor. + /// \param[in] _file Filename. + /// \param[in] _line Line number. + /// \param[in] _logLevel Log level. + public: LogMessage(const char *_file, + int _line, + spdlog::level::level_enum _logLevel); - /// \brief Output a warning message, if the verbose level is >= 2 - #define gzwarn (gz::common::Console::warn(__FILE__, __LINE__)) + /// \brief Destructor. + public: ~LogMessage(); - /// \brief Output a message, if the verbose level is >= 3 - #define gzmsg (gz::common::Console::msg()) + /// \brief Get access to the underlying stream. + /// \return The underlying stream. + public: std::ostream &stream(); - /// \brief Output a debug message, if the verbose level is >= 4 - #define gzdbg (gz::common::Console::dbg(__FILE__, __LINE__)) + /// \brief Log level. + private: spdlog::level::level_enum severity; - /// \brief Output a message to a log file, regardless of verbosity level - #define gzlog (gz::common::Console::log()) + /// \brief Source file location information. + private: spdlog::source_loc sourceLocation; + + /// \brief Underlying stream. + private: std::ostringstream ss; + }; + + /// \brief Output a critical message. + #define gzcrit (gz::common::LogMessage( \ + __FILE__, __LINE__, spdlog::level::critical).stream()) + + /// \brief Output an error message. + #define gzerr gz::common::LogMessage( \ + __FILE__, __LINE__, spdlog::level::err).stream() + + /// \brief Output a warning message. + #define gzwarn gz::common::LogMessage( \ + __FILE__, __LINE__, spdlog::level::warn).stream() + + /// \brief Output a message to a log file. + #define gzlog gz::common::LogMessage( \ + __FILE__, __LINE__, spdlog::level::err).stream() + + /// \brief Output a message. + #define gzmsg gz::common::LogMessage( \ + __FILE__, __LINE__, spdlog::level::info).stream() + + /// \brief Output a debug message. + #define gzdbg gz::common::LogMessage( \ + __FILE__, __LINE__, spdlog::level::debug).stream() + + /// \brief Output a trace message. + #define gztrace gz::common::LogMessage( \ + __FILE__, __LINE__, spdlog::level::trace).stream() /// \brief Initialize log file with filename given by _dir/_file. /// If called twice, it will close the file currently in use and open a new @@ -53,194 +97,55 @@ namespace gz /// \param[in] _dir Name of directory in which to store the log file. Note /// that if _dir is not an absolute path, then _dir will /// be relative to your home directory. - /// \param[in] _file Name of log file for ignlog messages. + /// \param[in] _file Name of log file for gzlog messages. #define gzLogInit(_dir, _file)\ - gz::common::Console::log.Init(_dir, _file) + gz::common::Console::Init(_dir, _file) /// \brief Close the file used for logging. #define gzLogClose()\ - gz::common::Console::log.Close() + gz::common::Console::Close() /// \brief Get the full path of the directory where the log files are stored /// \return Full path of the directory #define gzLogDirectory()\ - (gz::common::Console::log.LogDirectory()) + (gz::common::Console::Directory()) - /// \class FileLogger FileLogger.hh common/common.hh - /// \brief A logger that outputs messages to a file. - class GZ_COMMON_VISIBLE FileLogger : public std::ostream + /// \class Console Console.hh common/common.hh + /// \brief Container for loggers, and global logging options + /// (such as verbose vs. quiet output). + class GZ_COMMON_VISIBLE Console : public gz::utils::log::Logger { - /// \brief Constructor. - /// \param[in] _filename Filename to write into. If empty, - /// FileLogger::Init must be called separately. - public: explicit FileLogger(const std::string &_filename = ""); + /// \brief Class constructor. + /// \param[in] _loggerName Logger name. + public: explicit Console(const std::string &_loggerName); - /// \brief Destructor. - public: virtual ~FileLogger(); + /// \brief Access the global gz console logger. + /// \return The gz consoler logger. + public: static Console &Root(); - /// \brief Initialize the file logger. + /// \brief Initialize the global logger. /// \param[in] _directory Name of directory that holds the log file. /// \param[in] _filename Name of the log file to write output into. - public: void Init(const std::string &_directory, - const std::string &_filename); - - /// \brief Close the open file handles. - public: void Close(); - - /// \brief Output a filename and line number, then return a reference - /// to the logger. - /// \return Reference to this logger. - public: virtual FileLogger &operator()(); - - /// \brief Output a filename and line number, then return a reference - /// to the logger. - /// \param[in] _file Filename to output. - /// \param[in] _line Line number in the _file. - /// \return Reference to this logger. - public: virtual FileLogger &operator()( - const std::string &_file, int _line); - + /// \return True when the initialization succeed or false otherwise. + public: static bool Init(const std::string &_directory, + const std::string &_filename); + + /// \brief Detach fhe file sink from the global logger. After this call, + /// console logging will keep working but no file logging. + public: static void Close(); + /// \brief Get the full path of the directory where all the log files /// are stored. /// \return Full path of the directory. - public: std::string LogDirectory() const; - - /// \brief String buffer for the file logger. - protected: class Buffer : public std::stringbuf - { - /// \brief Constructor. - /// \param[in] _filename Filename to write into. - public: explicit Buffer(const std::string &_filename); - - /// \brief Destructor. - public: virtual ~Buffer(); - - /// \brief Writes _count characters to the string buffer - /// \param[in] _char Input rharacter array. - /// \param[in] _count Number of characters in array. - /// \return The number of characters successfully written. - public: std::streamsize xsputn( - const char *_char, std::streamsize _count) override; - - /// \brief Sync the stream (output the string buffer - /// contents). - /// \return Return 0 on success. - public: int sync() override; - - /// \brief Stream to output information into. - public: std::ofstream *stream; - - /// \brief Mutex to synchronize writes to the string buffer - /// and the output stream. - public: std::mutex syncMutex; - }; - - GZ_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING - /// \brief Stores the full path of the directory where all the log files - /// are stored. - private: std::string logDirectory; - GZ_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING - - /// \brief True if initialized. - private: bool initialized; - }; - - /// \class Logger Logger.hh common/common.hh - /// \brief Terminal logger. - class GZ_COMMON_VISIBLE Logger : public std::ostream - { - /// \enum LogType. - /// \brief Output destination type. - public: enum LogType - { - /// \brief Output to stdout. - STDOUT, - /// \brief Output to stderr. - STDERR - }; - - /// \brief Constructor. - /// \param[in] _prefix String to use as prefix when logging to file. - /// \param[in] _color Color of the output stream. - /// \param[in] _type Output destination type (STDOUT, or STDERR) - /// \param[in] _verbosity Verbosity level. - public: Logger(const std::string &_prefix, const int _color, - const LogType _type, const int _verbosity); - - /// \brief Destructor. - public: virtual ~Logger(); - - /// \brief Access operator. - /// \return Reference to this logger. - public: virtual Logger &operator()(); - - /// \brief Output a filename and line number, then return a reference - /// to the logger. - /// \param[in] _file Filename to output. - /// \param[in] _line Line number in the _file. - /// \return Reference to this logger. - public: virtual Logger &operator()( - const std::string &_file, int _line); - - /// \brief String buffer for the base logger. - protected: class Buffer : public std::stringbuf - { - /// \brief Constructor. - /// \param[in] _type Output destination type - /// (STDOUT, or STDERR) - /// \param[in] _color Color of the output stream. - /// \param[in] _verbosity Verbosity level. - public: Buffer(LogType _type, const int _color, - const int _verbosity); - - /// \brief Destructor. - public: virtual ~Buffer(); - - /// \brief Writes _count characters to the string buffer - /// \param[in] _char Input rharacter array. - /// \param[in] _count Number of characters in array. - /// \return The number of characters successfully written. - public: std::streamsize xsputn( - const char *_char, std::streamsize _count) override; - - /// \brief Sync the stream (output the string buffer - /// contents). - /// \return Return 0 on success. - public: int sync() override; - - /// \brief Destination type for the messages. - public: LogType type; - - /// \brief ANSI color code using Select Graphic Rendition - /// parameters (SGR). See - /// http://en.wikipedia.org/wiki/ANSI_escape_code#Colors - public: int color; - - /// \brief Level of verbosity - public: int verbosity; + public: static std::string Directory(); - /// \brief Mutex to synchronize writes to the string buffer - /// and the output stream. - public: std::mutex syncMutex; - }; - - GZ_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING - /// \brief Prefix to use when logging to file. - private: std::string prefix; - GZ_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING - }; - - /// \class Console Console.hh common/common.hh - /// \brief Container for loggers, and global logging options - /// (such as verbose vs. quiet output). - class GZ_COMMON_VISIBLE Console - { /// \brief Set verbosity, where - /// <= 0: No output, - /// 1: Error messages, - /// 2: Error and warning messages, - /// 3: Error, warning, and info messages, - /// >= 4: Error, warning, info, and debug messages. + /// 0: Critical messages, + /// 1: Critical, error messages, + /// 2: Critical, error and warning messages, + /// 3: Critical, error, warning, and info messages, + /// 4: Critical, error, warning, info, and debug messages. + /// 5: Critical, error, warning, info, debug, and trace messages. /// \param[in] _level The new verbose level. public: static void SetVerbosity(const int _level); @@ -269,20 +174,8 @@ namespace gz /// \sa void SetPrefix(const std::string &_customPrefix) public: static std::string Prefix(); - /// \brief Global instance of the message logger. - public: static Logger msg; - - /// \brief Global instance of the error logger. - public: static Logger err; - - /// \brief Global instance of the debug logger. - public: static Logger dbg; - - /// \brief Global instance of the warning logger. - public: static Logger warn; - - /// \brief Global instance of the file logger. - public: static FileLogger log; + /// \brief True if initialized. + public: static bool initialized; /// \brief The level of verbosity, the default level is 1. private: static int verbosity; @@ -290,6 +183,10 @@ namespace gz GZ_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING /// \brief A custom prefix. See SetPrefix(). private: static std::string customPrefix; + + /// \brief Stores the full path of the directory where all the log files + /// are stored. + private: std::string logDirectory; GZ_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING }; } diff --git a/package.xml b/package.xml index e840d76f..ad6da2f3 100644 --- a/package.xml +++ b/package.xml @@ -18,6 +18,7 @@ gz-utils3 libfreeimage-dev libgdal-dev + spdlog tinyxml2 uuid diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 773f29f4..a0dc9a8f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -18,7 +18,8 @@ target_link_libraries(${PROJECT_LIBRARY_TARGET_NAME} PRIVATE ${CXX_FILESYSTEM_LIBRARIES} PUBLIC - gz-utils${GZ_UTILS_VER}::gz-utils${GZ_UTILS_VER} + gz-utils${GZ_UTILS_VER}::log + spdlog::spdlog ) # Handle non-Windows configuration settings @@ -42,7 +43,7 @@ gz_build_tests( TYPE UNIT SOURCES ${gtest_sources} LIB_DEPS - gz-utils${GZ_UTILS_VER}::gz-utils${GZ_UTILS_VER} + gz-utils${GZ_UTILS_VER}::log gz-common${GZ_COMMON_VER}-testing INCLUDE_DIRS # Used to make internal source file headers visible to the unit tests diff --git a/src/Console.cc b/src/Console.cc index 238e37e6..ca231d99 100644 --- a/src/Console.cc +++ b/src/Console.cc @@ -14,223 +14,71 @@ * limitations under the License. * */ -#include -#include - -#include -#include -#include +#include #ifdef _WIN32 #include #endif -using namespace gz; -using namespace common; - - -FileLogger common::Console::log(""); - -// On UNIX, these are ANSI-based color codes. On Windows, these are colors from -// docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences . -// They happen to overlap, but there might be differences if more colors are -// added. -const int red = 31; -const int yellow = 33; -const int green = 32; -const int blue = 36; - -Logger Console::err("[Err] ", red, Logger::STDERR, 1); -Logger Console::warn("[Wrn] ", yellow, Logger::STDERR, 2); -Logger Console::msg("[Msg] ", green, Logger::STDOUT, 3); -Logger Console::dbg("[Dbg] ", blue, Logger::STDOUT, 4); - -int Console::verbosity = 1; -std::string Console::customPrefix = ""; // NOLINT(*) - -////////////////////////////////////////////////// -void Console::SetVerbosity(const int _level) -{ - verbosity = _level; -} - -////////////////////////////////////////////////// -int Console::Verbosity() -{ - return verbosity; -} - -////////////////////////////////////////////////// -void Console::SetPrefix(const std::string &_prefix) -{ - customPrefix = _prefix; -} - -////////////////////////////////////////////////// -std::string Console::Prefix() -{ - return customPrefix; -} - -///////////////////////////////////////////////// -Logger::Logger(const std::string &_prefix, const int _color, - const LogType _type, const int _verbosity) -: std::ostream(new Buffer(_type, _color, _verbosity)), prefix(_prefix) -{ - this->setf(std::ios_base::unitbuf); -} - -///////////////////////////////////////////////// -Logger::~Logger() -{ -} - -///////////////////////////////////////////////// -Logger &Logger::operator()() -{ - Console::log() << "(" << common::systemTimeIso() << ") "; - (*this) << Console::Prefix() << this->prefix; - - return (*this); -} - -///////////////////////////////////////////////// -Logger &Logger::operator()(const std::string &_file, int _line) -{ - int index = _file.find_last_of("/") + 1; +#include +#include +#include +#include +#include - Console::log() << "(" << common::systemTimeIso() << ") "; - std::stringstream prefixString; - prefixString << Console::Prefix() << this->prefix - << "[" << _file.substr(index , _file.size() - index) << ":" - << _line << "] "; - (*this) << prefixString.str(); +#include +#include +#include +#include +#include - return (*this); -} +using namespace gz; +using namespace common; ///////////////////////////////////////////////// -Logger::Buffer::Buffer(LogType _type, const int _color, const int _verbosity) - : type(_type), color(_color), verbosity(_verbosity) +LogMessage::LogMessage(const char *_file, int _line, + spdlog::level::level_enum _logLevel) + : severity(_logLevel), + sourceLocation(_file, _line, "") { + // Use default initialization if needed. + if (!Console::initialized) + Console::Init(".gz", "auto_default.log"); } ///////////////////////////////////////////////// -Logger::Buffer::~Buffer() +LogMessage::~LogMessage() { - this->pubsync(); + gz::common::Console::Root().RawLogger().log( + this->sourceLocation, this->severity, + gz::common::Console::Prefix() + this->ss.str()); } ///////////////////////////////////////////////// -std::streamsize Logger::Buffer::xsputn(const char *_char, - std::streamsize _count) +std::ostream &LogMessage::stream() { - std::lock_guard lk(this->syncMutex); - return std::stringbuf::xsputn(_char, _count); + return this->ss; } -///////////////////////////////////////////////// -int Logger::Buffer::sync() -{ - std::string outstr; - { - std::lock_guard lk(this->syncMutex); - outstr = this->str(); - } - - // Log messages to disk - { - std::lock_guard lk(this->syncMutex); - Console::log << outstr; - Console::log.flush(); - } - - // Output to terminal - if (Console::Verbosity() >= this->verbosity && !outstr.empty()) - { -#ifndef _WIN32 - bool lastNewLine = outstr.back() == '\n'; - FILE *outstream = this->type == Logger::STDOUT ? stdout : stderr; - - if (lastNewLine) - outstr.pop_back(); - - std::stringstream ss; - ss << "\033[1;" << this->color << "m" << outstr << "\033[0m"; - if (lastNewLine) - ss << std::endl; - - { - std::lock_guard lk(this->syncMutex); - fprintf(outstream, "%s", ss.str().c_str()); - } -#else - HANDLE hConsole = CreateFileW( - L"CONOUT$", GENERIC_WRITE|GENERIC_READ, 0, nullptr, OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, nullptr); - - DWORD dwMode = 0; - bool vtProcessing = false; - if (GetConsoleMode(hConsole, &dwMode)) - { - if ((dwMode & ENABLE_VIRTUAL_TERMINAL_PROCESSING) > 0) - { - vtProcessing = true; - } - else - { - dwMode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING; - if (SetConsoleMode(hConsole, dwMode)) - vtProcessing = true; - } - } - - std::ostream &outStream = - this->type == Logger::STDOUT ? std::cout : std::cerr; - - { - std::lock_guard lk(this->syncMutex); - if (vtProcessing) - outStream << "\x1b[" << this->color << "m" << outstr << "\x1b[m"; - else - outStream << outstr; - } -#endif - } - - { - std::lock_guard lk(this->syncMutex); - this->str(""); - } - return 0; -} +bool Console::initialized = false; +int Console::verbosity = 1; +std::string Console::customPrefix = ""; // NOLINT(*) ///////////////////////////////////////////////// -FileLogger::FileLogger(const std::string &_filename) - : std::ostream(new Buffer(_filename)), - logDirectory("") +Console::Console(const std::string &_loggerName) + : gz::utils::log::Logger(_loggerName) { - this->initialized = false; - this->setf(std::ios_base::unitbuf); } ///////////////////////////////////////////////// -FileLogger::~FileLogger() +Console &Console::Root() { - if (this->initialized && this->rdbuf()) - { - auto *buf = dynamic_cast(this->rdbuf()); - if (buf->stream) - { - delete buf->stream; - buf->stream = nullptr; - } - } + static gz::utils::NeverDestroyed root{"gz"}; + return root.Access(); } ///////////////////////////////////////////////// -void FileLogger::Init(const std::string &_directory, - const std::string &_filename) +bool Console::Init(const std::string &_directory, const std::string &_filename) { std::string logPath; @@ -248,7 +96,7 @@ void FileLogger::Init(const std::string &_directory, // trying to get the log initialized std::cerr << "Missing HOME environment variable." << "No log file will be generated." << std::endl; - return; + return false; } logPath = joinPaths(logPath, _directory); } @@ -257,122 +105,79 @@ void FileLogger::Init(const std::string &_directory, logPath = _directory; } - auto* buf = dynamic_cast(this->rdbuf()); - - // Create the directory if it doesn't exist. - createDirectories(logPath); - logPath = joinPaths(logPath, _filename); - // Check if the Init method has been already called, and if so - // remove current buffer. - if (buf->stream) - { - delete buf->stream; - buf->stream = nullptr; - } - - buf->stream = new std::ofstream(logPath.c_str(), std::ios::out); - if (!buf->stream->is_open()) - std::cerr << "Error opening log file: " << logPath << std::endl; - - // Update the log directory name. - if (isDirectory(logPath)) - this->logDirectory = logPath; - else - this->logDirectory = common::parentPath(logPath); + Console::Root().SetLogDestination(logPath.c_str()); + Console::initialized = true; - this->initialized = true; - - /// \todo(anyone) Reimplement this. - // Output the version of the project. - // (*buf->stream) << PROJECT_VERSION_HEADER << std::endl; + return true; } ///////////////////////////////////////////////// -void FileLogger::Close() +void Console::Close() { - auto* buf = dynamic_cast(this->rdbuf()); - if (buf && buf->stream && buf->stream->is_open()) - { - buf->stream->close(); - delete buf->stream; - buf->stream = nullptr; - } + // Detach the current file sink. + Console::Root().SetLogDestination(std::string()); } ///////////////////////////////////////////////// -FileLogger &FileLogger::operator()() +std::string Console::Directory() { - if (!this->initialized) - this->Init(".gz", "auto_default.log"); - - (*this) << "(" << common::systemTimeIso() << ") "; - return (*this); + std::filesystem::path path = gz::common::Console::Root().LogDestination(); + return path.parent_path().string(); } -///////////////////////////////////////////////// -FileLogger &FileLogger::operator()(const std::string &_file, int _line) -{ - if (!this->initialized) - this->Init(".gz", "auto_default.log"); - - int index = _file.find_last_of("/") + 1; - (*this) << "(" << common::systemTimeIso() << ") [" - << _file.substr(index , _file.size() - index) << ":" << _line << "]"; - - return (*this); -} - -///////////////////////////////////////////////// -std::string FileLogger::LogDirectory() const +////////////////////////////////////////////////// +void Console::SetVerbosity(const int _level) { - return this->logDirectory; -} + if (_level < 0) + { + Console::Root().RawLogger().log(spdlog::level::err, + "Negative verbosity level. Ignoring it"); + return; + } -///////////////////////////////////////////////// -FileLogger::Buffer::Buffer(const std::string &_filename) - : stream(NULL) -{ - if (!_filename.empty()) + switch (_level) { - this->stream = new std::ofstream(_filename.c_str(), std::ios::out); + case 0: + gz::common::Console::Root().SetConsoleSinkLevel(spdlog::level::critical); + break; + case 1: + gz::common::Console::Root().SetConsoleSinkLevel(spdlog::level::err); + break; + case 2: + gz::common::Console::Root().SetConsoleSinkLevel(spdlog::level::warn); + break; + case 3: + gz::common::Console::Root().SetConsoleSinkLevel(spdlog::level::info); + break; + case 4: + gz::common::Console::Root().SetConsoleSinkLevel(spdlog::level::debug); + break; + case 5: + gz::common::Console::Root().SetConsoleSinkLevel(spdlog::level::trace); + break; + default: + gz::common::Console::Root().SetConsoleSinkLevel(spdlog::level::trace); } + + verbosity = std::min(5, _level); } -///////////////////////////////////////////////// -FileLogger::Buffer::~Buffer() +////////////////////////////////////////////////// +int Console::Verbosity() { - if (this->stream) - static_cast(this->stream)->close(); + return verbosity; } -///////////////////////////////////////////////// -std::streamsize FileLogger::Buffer::xsputn(const char *_char, - std::streamsize _count) +////////////////////////////////////////////////// +void Console::SetPrefix(const std::string &_prefix) { - std::lock_guard lk(this->syncMutex); - return std::stringbuf::xsputn(_char, _count); + customPrefix = _prefix; } -///////////////////////////////////////////////// -int FileLogger::Buffer::sync() +////////////////////////////////////////////////// +std::string Console::Prefix() { - if (!this->stream) - return -1; - - { - std::lock_guard lk(this->syncMutex); - *this->stream << this->str(); - } - - { - std::lock_guard lk(this->syncMutex); - this->stream->flush(); - } - { - std::lock_guard lk(this->syncMutex); - this->str(""); - } - return !(*this->stream); + return customPrefix; } diff --git a/src/Console_TEST.cc b/src/Console_TEST.cc index 8e8c9543..97d65c32 100644 --- a/src/Console_TEST.cc +++ b/src/Console_TEST.cc @@ -48,6 +48,7 @@ class Console_TEST : public ::testing::Test { private: std::unique_ptr temp; }; +///////////////////////////////////////////////// std::string GetLogContent(const std::string &_filename) { // Get the absolute path @@ -89,7 +90,10 @@ TEST_F(Console_TEST, NoInitAndLog) std::string path; EXPECT_TRUE(common::env(GZ_HOMEDIR, path)); path = common::joinPaths(path, logPath); - EXPECT_TRUE(common::removeAll(path)); + + // This is causing an issue on Windows as the resource is busy, + // probably locked by spdlog. + common::removeAll(path); } ///////////////////////////////////////////////// @@ -119,7 +123,10 @@ TEST_F(Console_TEST, InitAndLog) // Cleanup gzLogClose(); - EXPECT_TRUE(common::removeAll(basePath)); + + // This is causing an issue on Windows as the resource is busy, + // probably locked by spdlog. + common::removeAll(basePath); } ////////////////////////////////////////////////// @@ -470,13 +477,16 @@ TEST_F(Console_TEST, ColorErr) /// \brief Test Console::Verbosity TEST_F(Console_TEST, Verbosity) { - EXPECT_EQ(common::Console::Verbosity(), 1); + EXPECT_EQ(1, common::Console::Verbosity()); common::Console::SetVerbosity(2); - EXPECT_EQ(common::Console::Verbosity(), 2); + EXPECT_EQ(2, common::Console::Verbosity()); common::Console::SetVerbosity(-1); - EXPECT_EQ(common::Console::Verbosity(), -1); + EXPECT_EQ(2, common::Console::Verbosity()); + + common::Console::SetVerbosity(1000); + EXPECT_EQ(5, common::Console::Verbosity()); } ///////////////////////////////////////////////// @@ -509,10 +519,10 @@ TEST_F(Console_TEST, Prefix) std::string logContent = GetLogContent(logPath); // Check - EXPECT_TRUE(logContent.find("**test** [Err]") != std::string::npos); - EXPECT_TRUE(logContent.find("**test** [Wrn]") != std::string::npos); - EXPECT_TRUE(logContent.find("**test** [Msg]") != std::string::npos); - EXPECT_TRUE(logContent.find("**test** [Dbg]") != std::string::npos); + EXPECT_TRUE(logContent.find("**test** error") != std::string::npos); + EXPECT_TRUE(logContent.find("**test** warning") != std::string::npos); + EXPECT_TRUE(logContent.find("**test** message") != std::string::npos); + EXPECT_TRUE(logContent.find("**test** debug") != std::string::npos); // Reset common::Console::SetPrefix(""); diff --git a/testing/src/AutoLogFixture_TEST.cc b/testing/src/AutoLogFixture_TEST.cc index 1fc8cb49..aa598711 100644 --- a/testing/src/AutoLogFixture_TEST.cc +++ b/testing/src/AutoLogFixture_TEST.cc @@ -30,5 +30,6 @@ TEST_F(AutoLogFixture, AutoLogFixture) Console::SetVerbosity(0); gzdbg << "This is a debug" << std::endl; + gz::common::Console::Root().RawLogger().flush(); EXPECT_FALSE(this->LogContent().empty()); } From ff19dee57136aff16f73369b76da4d68fdd53ece Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Wed, 28 Aug 2024 18:25:06 -0700 Subject: [PATCH 03/10] Prepare for gz-common6.0.0~pre2 release (#629) Signed-off-by: Ian Chen --- CMakeLists.txt | 2 +- Changelog.md | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7288c884..b9103b6f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,7 @@ set(GZ_CMAKE_VER ${gz-cmake4_VERSION_MAJOR}) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) -gz_configure_project(VERSION_SUFFIX pre1) +gz_configure_project(VERSION_SUFFIX pre2) #============================================================================ # Set project-specific options diff --git a/Changelog.md b/Changelog.md index e5cb87a0..e139732b 100644 --- a/Changelog.md +++ b/Changelog.md @@ -4,6 +4,12 @@ 1. **Baseline:** this includes all changes from 5.6.0 and earlier. +1. Experimenting with spdlog + * [Pull request #615](https://github.com/gazebosim/gz-common/pull/615) + +1. Update Changelog, README and prepare for gz-common6.0.0~pre1 release + * [Pull request #626](https://github.com/gazebosim/gz-common/pull/626) + 1. Use self-pipe trick to implement signal handlers * [Pull request #618](https://github.com/gazebosim/gz-common/pull/618) From 3f129c32c665ea53e1afc84f048284eed463c0ca Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Thu, 5 Sep 2024 15:13:31 -0700 Subject: [PATCH 04/10] Fix AssimpLoader collada texture coordinates (#634) Fixes UNIT_AssimpLoader_TEST with assimp 5.4.3. This should fix homebrew CI. This PR tweaks the way we checks for texture coordinates from assimp. Empty texture coordinate slots are now allowed as of assimp/assimp#5636. The new logic should be compatible with assimp 5.4.3 and prior versions Signed-off-by: Ian Chen --- graphics/src/AssimpLoader.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/graphics/src/AssimpLoader.cc b/graphics/src/AssimpLoader.cc index bcbd7096..4cf8cf33 100644 --- a/graphics/src/AssimpLoader.cc +++ b/graphics/src/AssimpLoader.cc @@ -650,14 +650,14 @@ SubMesh AssimpLoader::Implementation::CreateSubMesh( subMesh.AddVertex(vertex); subMesh.AddNormal(normal); // Iterate over sets of texture coordinates - int uvIdx = 0; - while(_assimpMesh->HasTextureCoords(uvIdx)) + for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++i) { + if (!_assimpMesh->HasTextureCoords(i)) + continue; math::Vector3d texcoords; - texcoords.X(_assimpMesh->mTextureCoords[uvIdx][vertexIdx].x); - texcoords.Y(_assimpMesh->mTextureCoords[uvIdx][vertexIdx].y); - subMesh.AddTexCoordBySet(texcoords.X(), texcoords.Y(), uvIdx); - ++uvIdx; + texcoords.X(_assimpMesh->mTextureCoords[i][vertexIdx].x); + texcoords.Y(_assimpMesh->mTextureCoords[i][vertexIdx].y); + subMesh.AddTexCoordBySet(texcoords.X(), texcoords.Y(), i); } } for (unsigned faceIdx = 0; faceIdx < _assimpMesh->mNumFaces; ++faceIdx) From bbb3183b8787d62c879a3bdcd1f85ad56148046e Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Thu, 5 Sep 2024 15:30:40 -0700 Subject: [PATCH 05/10] Fix loading lightmaps from gltf / glb meshes (#630) Signed-off-by: Ian Chen --- graphics/src/AssimpLoader.cc | 56 +++++++++++++++++++++++++++--------- 1 file changed, 43 insertions(+), 13 deletions(-) diff --git a/graphics/src/AssimpLoader.cc b/graphics/src/AssimpLoader.cc index 4cf8cf33..d144dbab 100644 --- a/graphics/src/AssimpLoader.cc +++ b/graphics/src/AssimpLoader.cc @@ -16,9 +16,11 @@ */ #include +#include #include #include #include +#include #include "gz/common/graphics/Types.hh" #include "gz/common/AssimpLoader.hh" @@ -462,22 +464,50 @@ MaterialPtr AssimpLoader::Implementation::CreateMaterial( "Roughness")); pbr.SetRoughnessMap(texName, texData); } - // Load lightmap only if it is not a glb/glTF mesh that contains a - // MetallicRoughness texture - // It was found that lightmap field just stores the entire MetallicRoughness - // texture. Issues were also reported in assimp: - // https://github.com/assimp/assimp/issues/3120 - // https://github.com/assimp/assimp/issues/4637 - unsigned int uvIdx = 0; - ret = assimpMat->GetTexture( - aiTextureType_LIGHTMAP, 0, &texturePath, NULL, &uvIdx); - if (ret == AI_SUCCESS) + } + + // The lightmap / ambient occlusion texture may be the same texture as the + // metallicRoughness texture but it can also be a separate texture using a + // different uv index. In the former case, we expect the occlusion + // data to be packed in the R channel of the metallicRoughness texture, + // so load the occlusion data in the same ways as we do in the + // SplitMetallicRoughnessMap function. + // In the latter case (separate texture), no extra processing is + // required. + unsigned int uvIdx = 0; + ret = assimpMat->GetTexture( + aiTextureType_LIGHTMAP, 0, &texturePath, NULL, &uvIdx); + if (ret == AI_SUCCESS) + { + auto [texName, texData] = this->LoadTexture(_scene, texturePath, + this->GenerateTextureName(_fileBaseName, _scene, assimpMat, + "Lightmap")); + // Separate uv set so treat it as a separate texture + if (uvIdx > 0) { - auto [texName, texData] = this->LoadTexture(_scene, texturePath, - this->GenerateTextureName(_fileBaseName, _scene, assimpMat, - "Lightmap")); pbr.SetLightMap(texName, uvIdx, texData); } + // else split the occlusion data from the metallicRoughness texture + else + { + // R channel contains the occlusion data + // Note we are still creating an RGBA texture which seems watesful + // but that's what gz-rendering expects + auto origRGBAData = texData->RGBAData(); + std::vector texRData(origRGBAData.size()); + for (unsigned int i = 0; i < origRGBAData.size(); i+=4) + { + auto r = origRGBAData.at(i); + texRData[i] = r; + texRData[i + 1] = r; + texRData[i + 2] = r; + texRData[i + 3] = 255; + } + auto tex = std::make_shared(); + tex->SetFromData(&texRData[0], texData->Width(), texData->Height(), + Image::RGBA_INT8); + pbr.SetLightMap(texName, uvIdx, tex); + } } #endif ret = assimpMat->GetTexture(aiTextureType_NORMALS, 0, &texturePath); From 0a4a80f51b0a05fd5bc2b31e862f09b83b994b6c Mon Sep 17 00:00:00 2001 From: "Addisu Z. Taddese" Date: Fri, 6 Sep 2024 15:59:22 -0500 Subject: [PATCH 06/10] Fix severity level of gzlog (#635) The severity level of `gzlog` was incorrectly set to `err`. Changing this to `trace` solves two problems: 1. The log message is now a lot less alarming 2. When running `gz sim -v4`, this message is not shown on the console. It will only be logged to file. It does show up on the console if you run with `-v5`. The second point is technically a behavior change since in Harmonic, regardless of the verbosity level, `gzlog` would never show up on the console. However, duplicating that behavior with the new Console implementation proved to be very complicated. So, I propose we change the meaning of `gzlog` to be equivalent to `gztrace`. Signed-off-by: Addisu Z. Taddese --- graphics/src/ColladaLoader_TEST.cc | 1 + include/gz/common/Console.hh | 2 +- src/Console_TEST.cc | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/graphics/src/ColladaLoader_TEST.cc b/graphics/src/ColladaLoader_TEST.cc index 754f913d..3634b172 100644 --- a/graphics/src/ColladaLoader_TEST.cc +++ b/graphics/src/ColladaLoader_TEST.cc @@ -112,6 +112,7 @@ TEST_F(ColladaLoader, LoadZeroCount) common::testing::TestFile("data", "zero_count.dae")); ASSERT_TRUE(mesh); #ifndef _WIN32 + common::Console::Root().RawLogger().flush(); std::string log = LogContent(); // Expect no errors about missing values diff --git a/include/gz/common/Console.hh b/include/gz/common/Console.hh index a188de20..b20dffec 100644 --- a/include/gz/common/Console.hh +++ b/include/gz/common/Console.hh @@ -77,7 +77,7 @@ namespace gz /// \brief Output a message to a log file. #define gzlog gz::common::LogMessage( \ - __FILE__, __LINE__, spdlog::level::err).stream() + __FILE__, __LINE__, spdlog::level::trace).stream() /// \brief Output a message. #define gzmsg gz::common::LogMessage( \ diff --git a/src/Console_TEST.cc b/src/Console_TEST.cc index 97d65c32..5c31b9ce 100644 --- a/src/Console_TEST.cc +++ b/src/Console_TEST.cc @@ -82,6 +82,7 @@ TEST_F(Console_TEST, NoInitAndLog) // Get the absolute log file path std::string logPath = ".gz/auto_default.log"; + common::Console::Root().RawLogger().flush(); // Expect to find the string in the log file EXPECT_TRUE(GetLogContent(logPath).find(logString) != std::string::npos); @@ -118,6 +119,7 @@ TEST_F(Console_TEST, InitAndLog) // Get the absolute log file path std::string logPath = common::joinPaths(path, "test.log"); + common::Console::Root().RawLogger().flush(); // Expect to find the string in the log file EXPECT_TRUE(GetLogContent(logPath).find(logString) != std::string::npos); @@ -149,6 +151,7 @@ TEST_F(Console_TEST, LogSlashN) gzlog << logString << " _n__ " << i << '\n'; } + common::Console::Root().RawLogger().flush(); std::string logContent = GetLogContent(logPath); for (int i = 0; i < g_messageRepeat; ++i) @@ -179,6 +182,7 @@ TEST_F(Console_TEST, LogStdEndl) gzlog << logString << " endl " << i << std::endl; } + common::Console::Root().RawLogger().flush(); std::string logContent = GetLogContent(logPath); for (int i = 0; i < g_messageRepeat; ++i) From 3e26b228eec45cca3c052e41257f598417c8c90c Mon Sep 17 00:00:00 2001 From: Antoine Van Malleghem Date: Wed, 11 Sep 2024 20:45:15 +0200 Subject: [PATCH 07/10] fix table of content (#639) Signed-off-by: Van Malleghem Antoine --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f2e02e2c..fa9546f0 100644 --- a/README.md +++ b/README.md @@ -31,9 +31,9 @@ encoding/decoding to thread pools. [Folder Structure](#folder-structure) -[Code of Conduct](#code-of-conduct) +[Contributing](#contributing) -[Contributing](#code-of-contributing) +[Code of Conduct](#code-of-conduct) [Versioning](#versioning) From 427fa59171efc40e38b05160f6c225d79e9f2b80 Mon Sep 17 00:00:00 2001 From: Martin Pecka Date: Mon, 16 Sep 2024 17:56:39 +0200 Subject: [PATCH 08/10] docs/hw-encoding: Add a note about the conda-distributed ffmpeg on windows (#640) Signed-off-by: Martin Pecka --- tutorials/hw-encoding.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tutorials/hw-encoding.md b/tutorials/hw-encoding.md index 8885f58a..46500456 100644 --- a/tutorials/hw-encoding.md +++ b/tutorials/hw-encoding.md @@ -271,6 +271,14 @@ Just give them a try and dig deeper in the configuration if something is wrong. # Caveats +## FFMpeg on Windows via Conda + +The current distribution of FFMpeg via Conda for Windows does not include the h264_qsv +encoder. It only has h264_nvenc. This means that using Intel GPUs for HW acceleration is +not possible out of the box. A possible solution would be to build a custom build of +ffmpeg in the workspace with gz-common. Pull requests with the relevant tutorial are +welcome. + ## NVEnc per-machine limit If you have a multi-GPU station with desktop-class (not server-class) GPUs, you will From e2bd46c4739478a3f87f9eb0b55964ce3d0e0815 Mon Sep 17 00:00:00 2001 From: "Addisu Z. Taddese" Date: Thu, 26 Sep 2024 11:59:14 -0500 Subject: [PATCH 09/10] Prepare for 6.0.0 (#643) Signed-off-by: Addisu Z. Taddese --- CMakeLists.txt | 2 +- Changelog.md | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b9103b6f..492f754a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,7 @@ set(GZ_CMAKE_VER ${gz-cmake4_VERSION_MAJOR}) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) -gz_configure_project(VERSION_SUFFIX pre2) +gz_configure_project(VERSION_SUFFIX) #============================================================================ # Set project-specific options diff --git a/Changelog.md b/Changelog.md index e139732b..da5a649d 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,10 +1,25 @@ ## Gazebo Common 6.x -## Gazebo Common 6.0.0 (2024-09-XX) +## Gazebo Common 6.0.0 (2024-09-25) 1. **Baseline:** this includes all changes from 5.6.0 and earlier. -1. Experimenting with spdlog +1. Add a note about the conda-distributed ffmpeg on windows + * [Pull request #640](https://github.com/gazebosim/gz-common/pull/640) + +1. Fix table of content + * [Pull request #639](https://github.com/gazebosim/gz-common/pull/639) + +1. Fix severity level of gzlog + * [Pull request #635](https://github.com/gazebosim/gz-common/pull/635) + +1. Fix loading lightmaps from gltf / glb meshes + * [Pull request #630](https://github.com/gazebosim/gz-common/pull/630) + +1. Fix AssimpLoader collada texture coordinates + * [Pull request #634](https://github.com/gazebosim/gz-common/pull/634) + +1. Implement console logging using `spdlog` * [Pull request #615](https://github.com/gazebosim/gz-common/pull/615) 1. Update Changelog, README and prepare for gz-common6.0.0~pre1 release From 6b19c9e244c074477ab3dc14adb9dae0a50345dc Mon Sep 17 00:00:00 2001 From: Silvio Traversaro Date: Mon, 30 Sep 2024 09:53:15 +0200 Subject: [PATCH 10/10] Remove gts references from documentation (#645) Signed-off-by: Silvio Traversaro --- tutorials/install.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tutorials/install.md b/tutorials/install.md index 0dbcd78b..de75bcaa 100644 --- a/tutorials/install.md +++ b/tutorials/install.md @@ -71,7 +71,6 @@ Gazebo Common requires: The Graphics component requires: * [FreeImage](http://freeimage.sourceforge.net/) - * [GTS](http://gts.sourceforge.net/). The AV component requires: @@ -98,7 +97,7 @@ conda activate gz-ws Install prerequisites: ``` -conda install freeimage gdal gts glib dlfcn-win32 ffmpeg --channel conda-forge +conda install freeimage gdal glib dlfcn-win32 ffmpeg --channel conda-forge ``` Install Gazebo dependencies: