A question for anyone who might know. Would it be possible to use some kind of C++ stream to handle logfile routines such as the following?
So that rather than using stdarg in this manner, you would end up doing something more like this:
logfile of course being a global file stream which was opened to write to the log, or perhaps cout instad if you've got output being directed by the startup script.
log_printf( "%s: Unknown PC flag: %s\n\r", __FUNCTION__, flag );
void log_printf( const char *fmt, ... )
{
char buf[MSL*2];
char *strtime;
va_list args;
va_start( args, fmt );
vsnprintf( buf, MSL*2, fmt, args );
va_end( args );
strtime = ctime( ¤t_time );
strtime[strlen(strtime)-1] = '\0';
fprintf( stderr, "%s :: %s\n", strtime, buf );
}
So that rather than using stdarg in this manner, you would end up doing something more like this:
log_printf << __FUNCTION__ << ": Unknown PC flag: " << flag;
log_printf( whatever_should_go_here_to_indicate_it_uses_a_stream )
{
char *strtime;
strtime = ctime( ¤t_time );
strtime[strlen(strtime)-1] = '\0';
logfile << strtime << " :: " << the_argument_you_passed_here << endl;
}
logfile of course being a global file stream which was opened to write to the log, or perhaps cout instad if you've got output being directed by the startup script.