Feature request
Feature description
I'd like to have std::string (and possibly other common string containter) friendly logging macros.
For example, right now you must make logging calls like this:
std::string msg = "some error message from elsewhere";
RCLCPP_INFO(logger, ("some suffix: " + msg).c_str());
But I'd like to write:
std::string msg = "some error message from elsewhere";
RCLCPP_INFO(logger, "some suffix: " + msg);
// or just...
RCLCPP_INFO(logger, msg);
Implementation considerations
I think a helper function could make the macros simple, something like:
#include <string>
using namespace std::string_literals;
const char *
get_c_string(const char * string_in)
{
return string_in;
}
const char *
get_c_string(const std::string & string_in)
{
return string_in.c_str();
}
#define LOG_INFO(msg) printf("%s\n", get_c_string(msg));
int main()
{
LOG_INFO("plain c string");
std::string a_str("a local std::string");
LOG_INFO(a_str);
LOG_INFO(std::string("a temporary std::string"));
LOG_INFO("a std::string literal"s);
}
Feature request
Feature description
I'd like to have std::string (and possibly other common string containter) friendly logging macros.
For example, right now you must make logging calls like this:
But I'd like to write:
Implementation considerations
I think a helper function could make the macros simple, something like: