From: Jack Lange Date: Tue, 26 May 2009 03:15:54 +0000 (-0500) Subject: added debug implementation X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=commitdiff_plain;h=049bd4b28dffd450db3b0facefb992909dc0e9dc added debug implementation --- diff --git a/misc/network_servers/vtl/debug.cc b/misc/network_servers/vtl/debug.cc new file mode 100644 index 0000000..ce2cac8 --- /dev/null +++ b/misc/network_servers/vtl/debug.cc @@ -0,0 +1,38 @@ +#include "debug.h" +#include +#include +#include + +static FILE * logfile = NULL; +static int debug_on = 0; + +int vtl_debug_init(string logfilename, int debug_enable) { + debug_on = debug_enable; + logfile = fopen(logfilename.c_str(), "w+"); + return 0; +} + + + +void vtl_debug(const char * fmt, ...) { + if (debug_on) { + va_list args; + time_t dbgt; + struct tm * time_data; + char time_str[200]; + + time(&dbgt); + time_data = localtime(&dbgt); + + + strftime(time_str, sizeof(time_str), "%a %b %d %r %Y : ", time_data); + + fprintf(logfile, "%s", time_str); + + va_start(args, fmt); + vfprintf(logfile, fmt, args); + va_end(args); + + fflush(logfile); + } +}