c++ - Trying to combine two similar printf style debug messages in to a single function -


i have 2 printf style debug logging functions (debuglogfa, debuglogfb). both operate same way 1 of logging functions takes logging level parameters , ignores low level debug messages.

currently duplicate code each of these functions debuglogfb able call debuglogfa if debug level high enough without having create temporary buffer in debuglogfb.

void debuglogfa( const char *lpsztext, ...) {     //initialize variable argument list     va_list arglist;     va_start(arglist, lpsztext);      char buffer[1024];     unsigned short length = snprintf_s(buffer, 1024, "[%d] ", ctime::getcurrenttimeinsec() );     length += vsnprintf (buffer+length, 1024 - length, lpsztext, arglist );      logsend( buffer, length ); }  void debuglogfb ( const unsigned int level, const char *lpsztext, ... ) {     if( level < 50 ) {         return; // low report.      }      //initialize variable argument list     va_list arglist;     va_start(arglist, lpsztext);      char buffer[1024];     unsigned short length = snprintf_s(buffer, 1024, "[%d] ", ctime::getcurrenttimeinsec() );     length += vsnprintf (buffer+length, 1024 - length, lpsztext, arglist );      logsend( buffer, length ); } 

my question is:

how function debuglogfb call debuglogfa without creating buffer message in debuglogfb?

you create new function debuglogfv has const char *lpsztext , va_list arglist parameters, , let debuglogfa , debuglogfb call perform actual logging.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -