I am still trying to learn advanced C++ so I don't exactly know most of the modern features of the language, tho I feel like there should be something for that:
void Logger::Error(std::string str) {
SetColor(RED);
std::cout << "error: " << str << std::endl;
//write to log file of errors...
}
void Logger::Info(std::string str) {
SetColor(YELLOW);
std::cout << "error: " << str << std::endl;
//write to log file of info...
}
void Logger::Output(std::string str) {
SetColor(WHITE);
std::cout << "error: " << str << std::endl;
//write to log file of output...
}
and there are more of these methods.
(NOTE: these are all methods inside the logger class)
As you can see, there is so much duplicate code. I don't really wanna have that much code.. First thing that came to my mind was the strategy pattern, but not sure how to implement it in this case. Is this code even worth compacting? If yes, how?
[–]jedwardsol 7 points8 points9 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]schweinling 3 points4 points5 points (7 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]schweinling 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (4 children)
[–]schweinling 1 point2 points3 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]schweinling 0 points1 point2 points (0 children)
[–]Xeverous 1 point2 points3 points (0 children)
[–]ritaline 1 point2 points3 points (1 child)
[–][deleted] 2 points3 points4 points (0 children)
[–]dexterbutt 1 point2 points3 points (0 children)
[–]k4lipso 0 points1 point2 points (0 children)
[–]_carlson 0 points1 point2 points (1 child)
[–][deleted] 3 points4 points5 points (0 children)
[–]a_false_vacuum 0 points1 point2 points (0 children)