I have different parts of my application calling a log function to log data.
Class logger
std::string filename = "blahblah";
log4cpp::PropertyConfigurator::configure(filename);
void Logger::logging(const std::string& msg)
{
Log4cpp::Category& myLogger = log4cpp::Category::getRoot();
myLogger.log(log4cpp::Priority::INFO, msg);
}
Call class
Logger logMe;
int a = 5;
double b = 6;
logMe.logging("log this msg" + a + "," + b);
I realized that the above will give me an error, because athey bhave different types. One way to solve it is to usestd::to_string
logMe.logging("log this msg" + std::to_string(a) + "," + std::to_string(b));
However, I have hundreds of calls to the logging function, and it will take a lot of time to edit each call std::to_string. Is there / is there an easier way to do this?
Oh and to clarify, the code works earlier, since the previous method was to define the #define function.
do {\
...
clog << x; \
}while(0)
logging(LogFlag::Warning, "log this msg" << a << "," << b << endl);
But now I rewrite parts of the code to fit static testing.
Thanks in advance.