diff --git a/odc/Controller.cpp b/odc/Controller.cpp index d77e1f8..249e3ef 100644 --- a/odc/Controller.cpp +++ b/odc/Controller.cpp @@ -21,6 +21,7 @@ #include #include +#include // std::tolower #include using namespace odc; @@ -1314,12 +1315,26 @@ void Controller::fillAndLogFatalError(const CommonParams& common, Error& error, OLOG(fatal, common) << error.mDetails; } +void Controller::logLineWarningOrDetectedSev(const CommonParams& common, const string& line) +{ + string lowerCaseLine = line; + std::transform(lowerCaseLine.begin(), lowerCaseLine.end(), lowerCaseLine.begin(), [](unsigned char c){ return std::tolower(c); }); + + if (lowerCaseLine.find("fatal") != string::npos) { + OLOG(fatal, common) << line; + } else if (lowerCaseLine.find("error") != string::npos) { + OLOG(error, common) << line; + } else { + OLOG(warning, common) << line; + } +} + void Controller::logFatalLineByLine(const CommonParams& common, const string& msg) { stringstream ss(msg); string line; while (getline(ss, line, '\n')) { - OLOG(fatal, common) << line; + logLineWarningOrDetectedSev(common, line); } } @@ -1494,7 +1509,8 @@ string Controller::topoFilepath(const CommonParams& common, const string& topolo } if (exitCode != EXIT_SUCCESS) { - logFatalLineByLine(common, toString("Topology generation script failed with exit code: ", exitCode, ", stderr:\n", quoted(err), ",\nstdout:\n", quoted(shortOut), shortSuffix)); + OLOG(fatal, common) << "Topology generation script failed with exit code: " << exitCode; + logFatalLineByLine(common, toString(", stderr:\n", quoted(err), ",\nstdout:\n", quoted(shortOut), shortSuffix)); throw runtime_error(toString("Topology generation script failed with exit code: ", exitCode, ", stderr: ", quoted(err))); } diff --git a/odc/Controller.h b/odc/Controller.h index 8e3d8dc..f6b1878 100644 --- a/odc/Controller.h +++ b/odc/Controller.h @@ -154,6 +154,7 @@ class Controller void fillAndLogFatalError( const CommonParams& common, Error& error, ErrorCode errorCode, const std::string& msg); void fillAndLogFatalErrorLineByLine(const CommonParams& common, Error& error, ErrorCode errorCode, const std::string& msg); void logFatalLineByLine( const CommonParams& common, const std::string& msg); + void logLineWarningOrDetectedSev( const CommonParams& common, const std::string& line); RequestResult createRequestResult(const CommonParams& common, const Session& session, const Error& error, const std::string& msg, TopologyState&& topologyState, const std::unordered_set& hosts); RequestResult createRequestResult(const CommonParams& common, const std::string& sessionId, const Error& error, const std::string& msg, TopologyState&& topologyState, const std::unordered_set& hosts);