My thought process: I need to make a sub string out of a given string and return it. I find the first index for substr() with find().
Here is my code:
#include <string>
namespace log_line {
std::string message(std::string line) {
return line.substr(line.find("Invalid"));
}
std::string log_level(std::string line) {
// return the log level
return line.substr(line.find("ERROR"), 5);
}
std::string reformat(std::string line) {
// return the reformatted message
std::string first{line.substr(line.find("Operation"))};
std::string second{line.substr(line.find("INFO"), 4)};
std::string final{first + " (" + second + ")"};
return final;
}
} // namespace log_line
This is the error:
make[2]: *** [CMakeFiles/test_log-levels.dir/build.make:70: CMakeFiles/test_log-levels] Error 8
make[1]: *** [CMakeFiles/Makefile2:111: CMakeFiles/test_log-levels.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
I just don’t understand what the error means. Where do I need to look? I checked out the std::string docs on learncpp, I read about std::basic_string, I listened about namespaces from Bro Code.
I also tried to do it locally on my machine and it works.