35 #include <boost/filesystem.hpp> 37 namespace fs = boost::filesystem;
54 std::string log_file_name;
55 M_string::const_iterator it = remappings.find(
"__log");
56 if (it != remappings.end())
58 log_file_name = it->second;
64 if (log_file_name.empty())
69 std::string ros_log_env;
72 log_file_name = ros_log_env + std::string(
"/");
78 log_file_name = ros_log_env + std::string(
"/log/");
85 std::string dotros = ros_log_env + std::string(
"/.ros/");
86 fs::create_directory(dotros);
87 log_file_name = dotros +
"log/";
88 fs::create_directory(log_file_name);
107 std::snprintf(pid_str,
sizeof(pid_str),
"%d", pid);
108 log_file_name += std::string(
"_") + std::string(pid_str) + std::string(
".log");
111 log_file_name = fs::system_complete(log_file_name).string();
112 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