C Program to Log all Output to File

How to Write All Log Output into a File

The below C program for Writing All Output into File is a text based program. It can open the log file and replace calls to (f)printf by (f)printflog

C Program for Writing All Output into a File


FILE *log= NULL;
int printflog( const char *format, ... )
{
va_list arglist;
int ret;

va_start(arglist, format);
ret= vprintf(format, arglist);
if( log )
vfprintf(log, format, arglist);
return ret;
}

int fprintflog( FILE *stream, const char *format, ... )
{
va_list arglist;
int ret;

va_start(arglist, format);
ret= vfprintf(stream, format, arglist);
if( log )
vfprintf(log, format, arglist);
return ret;
}


Related Topic Basic Linux Commands
How to Download File command Line
How to Create tar.gz and tar.bz2
How to Include PHP in HTML File page
Servlet Interview Questions & Answers

nScraps.com 2011   Privacy Policy  Terms of Service  Feedback