35 #include <boost/filesystem.hpp> 41 #define snprintf _snprintf_s 45 namespace fs = boost::filesystem;
62 std::string log_file_name;
63 M_string::const_iterator it = remappings.find(
"__log");
64 if (it != remappings.end())
66 log_file_name = it->second;
72 if (log_file_name.empty())
77 std::string ros_log_env;
80 log_file_name = ros_log_env + std::string(
"/");
86 log_file_name = ros_log_env + std::string(
"/log/");
93 std::string dotros = ros_log_env + std::string(
"/.ros/");
94 fs::create_directory(dotros);
95 log_file_name = dotros +
"log/";
96 fs::create_directory(log_file_name);
106 log_file_name +=
'_';
115 snprintf(pid_str,
sizeof(pid_str),
"%d", pid);
116 log_file_name += std::string(
"_") + std::string(pid_str) + std::string(
".log");
119 log_file_name = fs::system_complete(log_file_name).string();
120 g_log_directory = fs::path(log_file_name).parent_path().string();
void init(const M_string &remappings)
ROSCPP_DECL const std::string & getName()
Returns the name of the current node.
std::map< std::string, std::string > M_string
bool get_environment_variable(std::string &str, const char *environment_variable)
ROSCPP_DECL const std::string & getLogDirectory()
std::string g_log_directory