diff --git a/opm/common/OpmLog/OpmLog.cpp b/opm/common/OpmLog/OpmLog.cpp index f72337f57..157956ac2 100644 --- a/opm/common/OpmLog/OpmLog.cpp +++ b/opm/common/OpmLog/OpmLog.cpp @@ -21,9 +21,17 @@ #include #include #include +#include // For isatty() etc. namespace Opm { + namespace { + bool stdoutIsTerminal() + { + return isatty(fileno(stdout)); + } + } + std::shared_ptr OpmLog::getLogger() { if (!m_logger) @@ -183,7 +191,7 @@ namespace Opm { std::shared_ptr streamLog = std::make_shared(std::cout, Log::DefaultMessageTypes); OpmLog::addBackend( "SimpleDefaultLog", streamLog); streamLog->setMessageLimiter(std::make_shared(message_limit)); - streamLog->setMessageFormatter(std::make_shared(use_prefix, use_color_coding)); + streamLog->setMessageFormatter(std::make_shared(use_prefix, use_color_coding && stdoutIsTerminal())); } /******************************************************************/