diff --git a/.github/scripts/run_build_ubuntu20_04.sh b/.github/scripts/run_build_ubuntu20_04.sh deleted file mode 100755 index a26f680..0000000 --- a/.github/scripts/run_build_ubuntu20_04.sh +++ /dev/null @@ -1,48 +0,0 @@ -CATKIN_PATH="$(which catkin)" - -if [ "$CATKIN_PATH" = "" ]; then - echo "Installing ros noetic" - - sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list' - sudo apt install curl - curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add - - sudo apt update - sudo apt install ros-noetic-ros-base - - source /opt/ros/noetic/setup.bash - - sudo apt install python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool build-essential python3-catkin-tools libgoogle-glog-dev - - sudo rosdep init - rosdep update - -else - sudo apt install -y libgoogle-glog-dev - echo "catkin found" -fi - -export DEBIAN_FRONTEND=noninteractive -BUILD_DIR=cmake-build - -if test -d "$BUILD_DIR"; then - rm -r $BUILD_DIR -else - mkdir $BUILD_DIR -fi - - -cmake CMakeLists.txt -B $BUILD_DIR/ -cd $BUILD_DIR || exit -cmake --build . --target test_default -- -j 6 -cmake --build . --target test_glog -- -j 6 -cmake --build . --target test_lpp -- -j 6 -cmake --build . --target test_lpp_custom -- -j 6 -cmake --build . --target test_nolog -- -j 6 -cmake --build . --target test_roslog -- -j 6 -cd devel/lib/lpp -./test_default -./test_glog -./test_lpp -./test_lpp_custom -./test_nolog -./test_roslog \ No newline at end of file diff --git a/include/log++.h b/include/log++.h index 3b9f4a6..206fe87 100644 --- a/include/log++.h +++ b/include/log++.h @@ -68,12 +68,12 @@ //! Check if libraries are available at compile time and include required headers #if __has_include() #include -#define GLOG_SUPPORTED +#define LPP_GLOG_SUPPORTED #endif #if __has_include() #include -#define ROSLOG_SUPPORTED +#define LPP_ROSLOG_SUPPORTED #endif //! Debug flag, If LPP_DEBUG is enabled, debug output should be printed. @@ -138,23 +138,23 @@ inline static Init lppInit; } //! assert if mode is supported by the libraries available -#if defined MODE_GLOG && !defined GLOG_SUPPORTED +#if defined MODE_GLOG && !defined LPP_GLOG_SUPPORTED #error Logging Mode is set to glog but glog was not found #endif -#if defined MODE_ROSLOG && !defined ROSLOG_SUPPORTED +#if defined MODE_ROSLOG && !defined LPP_ROSLOG_SUPPORTED #error Logging Mode is set to roslog but roslog was not found #endif //! Un-define glog`s LOG macro to avoid conflicts -#ifdef GLOG_SUPPORTED +#ifdef LPP_GLOG_SUPPORTED #undef LOG #endif //! Un-define log methods for redefinition -#if defined GLOG_SUPPORTED && !defined MODE_GLOG && !defined MODE_DEFAULT +#if defined LPP_GLOG_SUPPORTED && !defined MODE_GLOG && !defined MODE_DEFAULT #undef LOG_IF #undef LOG_EVERY_N #undef LOG_FIRST_N @@ -169,7 +169,7 @@ inline static Init lppInit; #undef LOG_STRING #endif -#if defined ROSLOG_SUPPORTED && !defined MODE_ROSLOG && !defined MODE_DEFAULT +#if defined LPP_ROSLOG_SUPPORTED && !defined MODE_ROSLOG && !defined MODE_DEFAULT #undef ROS_DEBUG #undef ROS_DEBUG_STREAM #undef ROS_INFO @@ -236,7 +236,7 @@ inline void LOG_INIT([[maybe_unused]] char *argv, [[maybe_unused]] const std::fu #endif #if defined MODE_GLOG || defined MODE_DEFAULT -#ifdef GLOG_SUPPORTED +#ifdef LPP_GLOG_SUPPORTED google::InitGoogleLogging(argv); FLAGS_logtostderr = true; lppInit.glog_initialized = true; @@ -250,21 +250,21 @@ inline void LOG_INIT([[maybe_unused]] char *argv, [[maybe_unused]] const std::fu #define LPP_ASSERT_GLOG(x) static_assert((x) == LPP_INTL::GlogSeverity::INFO || (x) == LPP_INTL::GlogSeverity::WARNING || (x) == LPP_INTL::GlogSeverity::ERROR || (x) == LPP_INTL::GlogSeverity::FATAL, "Unknown severity level") //! Hack to enable macro overloading. Used to overload glog's LOG() macro. -#define CAT(A, B) A ## B -#define SELECT(NAME, NUM) CAT( NAME ## _, NUM ) +#define LPP_CAT(A, B) A ## B +#define LPP_SELECT(NAME, NUM) LPP_CAT( NAME ## _, NUM ) -#define GET_COUNT(_1, _2, _3, _4, _5, _6, COUNT, ...) COUNT -#define VA_SIZE(...) GET_COUNT( __VA_ARGS__, 6, 5, 4, 3, 2, 1 ) -#define VA_SELECT(NAME, ...) SELECT( NAME, VA_SIZE(__VA_ARGS__) )(__VA_ARGS__) +#define LPP_GET_COUNT(_1, _2, _3, _4, _5, _6, COUNT, ...) COUNT +#define LPP_VA_SIZE(...) LPP_GET_COUNT( __VA_ARGS__, 6, 5, 4, 3, 2, 1 ) +#define LPP_VA_SELECT(NAME, ...) LPP_SELECT( NAME, LPP_VA_SIZE(__VA_ARGS__) )(__VA_ARGS__) //! Helper macros to generate warnings -#define DO_PRAGMA(x) _Pragma (#x) -#define LPP_WARN(x) DO_PRAGMA(message (#x)) +#define LPP_PRAGMA(x) _Pragma (#x) +#define LPP_WARN(x) LPP_PRAGMA(message (#x)) //! Overloads #pragma clang diagnostic push #pragma ide diagnostic ignored "OCUnusedMacroInspection" -#define LOG(...) VA_SELECT( LOG, __VA_ARGS__ ) +#define LOG(...) LPP_VA_SELECT( LOG, __VA_ARGS__ ) #pragma clang diagnostic pop /** @@ -402,9 +402,9 @@ if constexpr(LPP_INTL::LppSeverity::severity == LPP_INTL::LppSeverity::I */ [[maybe_unused]] inline static int32_t LPP_FLAGS_v; -#ifdef GLOG_SUPPORTED +#ifdef LPP_GLOG_SUPPORTED #define FLAGS_v LPP_FLAGS_v -#endif //GLOG_SUPPORTED +#endif //LPP_GLOG_SUPPORTED #endif //defined MODE_ROSLOG || defined MODE_LPP || MODE_NOLOG #if defined MODE_ROSLOG || defined MODE_LPP @@ -966,4 +966,8 @@ class LppGlogExtensionLog : public InternalPolicyLog { #define LPP_GET_KEY() std::string(__FILE__) + std::to_string(__LINE__) #pragma clang diagnostic pop +// Undefine macros that are only needed in this file +#undef LPP_GLOG_SUPPORTED +#undef LPP_ROSLOG_SUPPORTED + #endif //LOG__LOG_H_