--- In [email protected], Thomas Hruska <[EMAIL PROTECTED]> wrote:
>
> mano M wrote:
> > Hi,
> > I am trying to write a logger program using a singletone class.  I
built a class ,it works as given below..
> > InfoLog("Error .......");
> > or
> > InfoLog("Error" + "....");
> > But I trying to make this to work as below...
> > int ERROR_CODE;
> > InfoLog("Error .......",ERROR_CODE);
> > or
> > InfoLog("Error" , "....","...");
> > I mean it should work with different arguments.
> > Could you pl. suggest some ideas
> > Thanks,
> > Manoj
> 
> Your second example indicates you are "adding" two strings together in 
> some fashion...I'm pretty sure that shouldn't work - you'll be adding 
> the addresses of the two strings and passing those in.
> 
> Basically, use a versatile string class as the input for each
parameter. 
>   BString() is what I would personally use - much more versatile than 
> std::string.
> 
> -- 
> Thomas Hruska
> CubicleSoft President
> Ph: 517-803-4197
> 
> *NEW* MyTaskFocus 1.1
> Get on task.  Stay on task.
> 
> http://www.CubicleSoft.com/MyTaskFocus/
>

try varg functions
here is something i wrote


static void Log(int iLevel, char *pzFormat, ...);

void Logger::Log(int iLevel, char *pzFormat, ...)
{
        va_list args;
        va_start(args, pzFormat);
        char zBuf[1000];
 
        const char *zLevel = (iLevel == 1)? "DEBUG" :(iLevel == 2)?
"WARNING" : (iLevel==3)? "ERROR" : "INFO" ;
        vsnprintf(zBuf, 1000 , pzFormat, args);
        zBuf[999]= 0;
 
        va_end(args);
 
        printf("**%s** %s", zLevel, zBuf);
        fflush(stdout);

}

Reply via email to