Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable rosout.log by using environment variable #1425

Merged
merged 9 commits into from
Aug 8, 2018
16 changes: 12 additions & 4 deletions tools/rosout/rosout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,18 @@ class Rosout

void init()
{
bool disable_file_logging = false;
node_.getParamCached("/rosout/disable_file_logging", disable_file_logging);

if (!disable_file_logging)
const char* disable_file_logging_env = getenv("ROSOUT_DISABLE_FILE_LOGGING");
std::string disable_file_logging(disable_file_logging_env ? disable_file_logging_env : "");
std::transform(
disable_file_logging.begin(),
disable_file_logging.end(),
disable_file_logging.begin(),
[](char c){ return std::tolower(c); });
if (disable_file_logging.empty() || // Not set or set to empty string.
disable_file_logging == "0" ||
disable_file_logging == "false" ||
disable_file_logging == "off" ||
disable_file_logging == "no")
{
handle_ = fopen(log_file_name_.c_str(), "w");

Expand Down