X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=blobdiff_plain;f=misc%2Fnetwork_servers%2Fvtl%2Fdebug.cc;fp=misc%2Fnetwork_servers%2Fvtl%2Fdebug.cc;h=ce2cac8cf713c822bb64ff452ec57668c9261532;hp=0000000000000000000000000000000000000000;hb=049bd4b28dffd450db3b0facefb992909dc0e9dc;hpb=6fbb40991e6c6dc5cd247ffe3d21413722bfbfce 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); + } +}