7 #if __cplusplus < 201103L 8 #error rosfmt needs C++11 support. Suggestion: add "set(CMAKE_CXX_STANDARD 11)" \ 9 to your CMakeLists.txt. 22 std::string
vformat(fmt::string_view format_str, fmt::format_args args);
24 template<
typename ... Args>
25 std::string format(
const std::string& formatString,
const Args& ... args)
27 fmt::format_arg_store<fmt::format_context, Args...> as{args...};
31 template<
typename... Args>
34 const char* file,
int line,
const char*
function,
35 const std::string& format,
const Args&... args)
37 std::string
s = rosfmt::format(format, args...);
45 #define ROSFMT_PRINT_AT_LOCATION_WITH_FILTER(filter, ...) \ 46 ::rosfmt::print(filter, __rosconsole_define_location__loc.logger_, __rosconsole_define_location__loc.level_, __FILE__, __LINE__, __ROSCONSOLE_FUNCTION__, __VA_ARGS__) 48 #define ROSFMT_PRINT_AT_LOCATION(...) \ 49 ROSFMT_PRINT_AT_LOCATION_WITH_FILTER(NULL, __VA_ARGS__) 60 #define ROSFMT_LOG_COND(cond, level, name, ...) \ 63 ROSCONSOLE_DEFINE_LOCATION(cond, level, name); \ 65 if (ROS_UNLIKELY(__rosconsole_define_location__enabled)) \ 67 ROSFMT_PRINT_AT_LOCATION(__VA_ARGS__); \ 77 #define ROSFMT_LOG_ONCE(level, name, ...) \ 80 ROSCONSOLE_DEFINE_LOCATION(true, level, name); \ 81 static bool hit = false; \ 82 if (ROS_UNLIKELY(__rosconsole_define_location__enabled) && ROS_UNLIKELY(!hit)) \ 85 ROSFMT_PRINT_AT_LOCATION(__VA_ARGS__); \ 96 #define ROSFMT_LOG_THROTTLE(period, level, name, ...) \ 99 ROSCONSOLE_DEFINE_LOCATION(true, level, name); \ 100 static double last_hit = 0.0; \ 101 ::ros::Time now = ::ros::Time::now(); \ 102 if (ROS_UNLIKELY(__rosconsole_define_location__enabled) && ROS_UNLIKELY(last_hit + period <= now.toSec())) \ 104 last_hit = now.toSec(); \ 105 ROSFMT_PRINT_AT_LOCATION(__VA_ARGS__); \ 116 #define ROSFMT_LOG_DELAYED_THROTTLE(period, level, name, ...) \ 119 ROSCONSOLE_DEFINE_LOCATION(true, level, name); \ 120 ::ros::Time __ros_log_delayed_throttle__now__ = ::ros::Time::now(); \ 121 static double __ros_log_delayed_throttle__last_hit__ = __ros_log_delayed_throttle__now__.toSec(); \ 122 if (ROS_UNLIKELY(__rosconsole_define_location__enabled) && ROS_UNLIKELY(__ros_log_delayed_throttle__last_hit__ + period <= __ros_log_delayed_throttle__now__.toSec())) \ 124 __ros_log_delayed_throttle__last_hit__ = __ros_log_delayed_throttle__now__.toSec(); \ 125 ROSFMT_PRINT_AT_LOCATION(__VA_ARGS__); \ 136 #define ROSFMT_LOG_FILTER(filter, level, name, ...) \ 139 ROSCONSOLE_DEFINE_LOCATION(true, level, name); \ 140 if (ROS_UNLIKELY(__rosconsole_define_location__enabled) && (filter)->isEnabled()) \ 142 ROSFMT_PRINT_AT_LOCATION_WITH_FILTER(filter, __VA_ARGS__); \ 152 #define ROSFMT_LOG(level, name, ...) ROSFMT_LOG_COND(true, level, name, __VA_ARGS__) 154 #include "macros_generated.h" 158 #endif // include guard
ROSCONSOLE_DECL void print(FilterBase *filter, void *logger, Level level, const char *file, int line, const char *function, const char *fmt,...) ROSCONSOLE_PRINTF_ATTRIBUTE(7
std::string vformat(fmt::string_view format_str, fmt::format_args args)