7 #if __cplusplus < 201103L 8 #error rosfmt needs C++11 support. Suggestion: add "set(CMAKE_CXX_STANDARD 11)" \ 9 to your CMakeLists.txt. 14 #ifndef ROSFMT_NO_DEPRECATED_OSTREAM 15 #ifndef FMT_DEPRECATED_OSTREAM 16 #define FMT_DEPRECATED_OSTREAM 29 std::string
vformat(fmt::string_view format_str, fmt::format_args args);
31 template<
typename ... Args>
32 std::string format(
const std::string& formatString,
const Args& ... args)
34 fmt::format_arg_store<fmt::format_context, Args...> as{args...};
38 template<
typename... Args>
41 const char* file,
int line,
const char*
function,
42 fmt::format_string<Args...> fmt, Args&&... args)
44 std::string
s =
rosfmt::vformat(fmt, fmt::make_format_args(std::forward<Args>(args)...));
52 #define ROSFMT_PRINT_AT_LOCATION_WITH_FILTER(filter, ...) \ 53 ::rosfmt::print(filter, __rosconsole_define_location__loc.logger_, __rosconsole_define_location__loc.level_, __FILE__, __LINE__, __ROSCONSOLE_FUNCTION__, __VA_ARGS__) 55 #define ROSFMT_PRINT_AT_LOCATION(...) \ 56 ROSFMT_PRINT_AT_LOCATION_WITH_FILTER(NULL, __VA_ARGS__) 67 #define ROSFMT_LOG_COND(cond, level, name, ...) \ 70 ROSCONSOLE_DEFINE_LOCATION(cond, level, name); \ 72 if (ROS_UNLIKELY(__rosconsole_define_location__enabled)) \ 74 ROSFMT_PRINT_AT_LOCATION(__VA_ARGS__); \ 84 #define ROSFMT_LOG_ONCE(level, name, ...) \ 87 ROSCONSOLE_DEFINE_LOCATION(true, level, name); \ 88 static bool hit = false; \ 89 if (ROS_UNLIKELY(__rosconsole_define_location__enabled) && ROS_UNLIKELY(!hit)) \ 92 ROSFMT_PRINT_AT_LOCATION(__VA_ARGS__); \ 103 #define ROSFMT_LOG_THROTTLE(period, level, name, ...) \ 106 ROSCONSOLE_DEFINE_LOCATION(true, level, name); \ 107 static double last_hit = 0.0; \ 108 ::ros::Time now = ::ros::Time::now(); \ 109 if (ROS_UNLIKELY(__rosconsole_define_location__enabled) && ROS_UNLIKELY(last_hit + period <= now.toSec())) \ 111 last_hit = now.toSec(); \ 112 ROSFMT_PRINT_AT_LOCATION(__VA_ARGS__); \ 123 #define ROSFMT_LOG_DELAYED_THROTTLE(period, level, name, ...) \ 126 ROSCONSOLE_DEFINE_LOCATION(true, level, name); \ 127 ::ros::Time __ros_log_delayed_throttle__now__ = ::ros::Time::now(); \ 128 static double __ros_log_delayed_throttle__last_hit__ = __ros_log_delayed_throttle__now__.toSec(); \ 129 if (ROS_UNLIKELY(__rosconsole_define_location__enabled) && ROS_UNLIKELY(__ros_log_delayed_throttle__last_hit__ + period <= __ros_log_delayed_throttle__now__.toSec())) \ 131 __ros_log_delayed_throttle__last_hit__ = __ros_log_delayed_throttle__now__.toSec(); \ 132 ROSFMT_PRINT_AT_LOCATION(__VA_ARGS__); \ 143 #define ROSFMT_LOG_FILTER(filter, level, name, ...) \ 146 ROSCONSOLE_DEFINE_LOCATION(true, level, name); \ 147 if (ROS_UNLIKELY(__rosconsole_define_location__enabled) && (filter)->isEnabled()) \ 149 ROSFMT_PRINT_AT_LOCATION_WITH_FILTER(filter, __VA_ARGS__); \ 159 #define ROSFMT_LOG(level, name, ...) ROSFMT_LOG_COND(true, level, name, __VA_ARGS__) 161 #include "macros_generated.h" 165 #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)