An elternative to ellipses?

Started by
2 comments, last by Sneftel 18 years, 2 months ago
Hello! I have a logging class to log all errors/warnings and other messages in my project. The log function goes like so :
[source lang=cpp]
//------------------------------------------------------
// AddLogEntry
//
// Adds a log entry into the html file
//------------------------------------------------------
bool BGL::CBGLLogger::AddLogEntry(LOGTYPE logtype,
char * const codelocation, char * const entry, bool logged, bool     messageboxed, bool printfed, ...)
{
	if((int)logtype < m_bFileLoggingMinLevel) return true;

    va_list args;
    
    va_start(args, printfed);
    char * message = new char[_vscprintf(entry,args)];
    vsprintf(message,entry,args);



... and then "message" is outputted into a file. a sample call:

BGL::Logger.AddLogEntry(BGL::CBGLLogger::LOGTYPE_USELESSINFO,
"BGL::CBGL3dsLoader::Load()","My text hey, look it's myvariable : %i", true, false, true, myvariable);
However my code uses ellipses and old output functions, I which to correct that. How can I arrange my code so it doesn't use ellipses but still can output different types of variables along with the text (float, int, double) ? Anyone has a proposition? Or another way to handle the problem?
Advertisement
Look into boost::format. It's hackish, but a lot of modern C++ is hackish.
But then, must I include some boost headers in all of my files that need logging variables along with text?
Yes, but indirectly. You'd probably include it in the logger header file.

This topic is closed to new replies.

Advertisement