forgot to add files

This commit is contained in:
False.Genesis 2007-01-12 14:37:07 +00:00
parent fa4385c74f
commit f93fd5e246
2 changed files with 96 additions and 0 deletions

84
src/Client/log.cpp Normal file
View File

@ -0,0 +1,84 @@
#include <stdarg.h>
#include "common.h"
#include "PseuWoW.h"
#include "log.h"
PseuInstance *instance=NULL;
FILE *logfile=NULL;
void log_prepare(char *fn, PseuInstance* p)
{
logfile = fopen(fn,"a");
instance = p;
}
void log(const char *str, ...)
{
if(!str)
return;
va_list ap;
va_start(ap, str);
vprintf( str, ap );
va_end(ap);
printf("\n");
if(logfile)
{
fprintf(logfile, getDateString().c_str());
va_start(ap, str);
vfprintf(logfile, str, ap);
fprintf(logfile, "\n" );
va_end(ap);
fflush(logfile);
}
fflush(stdout);
}
void logdetail(const char *str, ...)
{
if(!str || instance->GetConf()->debug < 1)
return;
va_list ap;
va_start(ap, str);
vprintf( str, ap );
va_end(ap);
printf("\n");
if(logfile)
{
fprintf(logfile, getDateString().c_str());
va_start(ap, str);
vfprintf(logfile, str, ap);
fprintf(logfile, "\n" );
va_end(ap);
fflush(logfile);
}
fflush(stdout);
}
void logdebug(const char *str, ...)
{
if(!str || instance->GetConf()->debug < 2)
return;
va_list ap;
va_start(ap, str);
vprintf( str, ap );
va_end(ap);
printf("\n");
if(logfile)
{
fprintf(logfile, getDateString().c_str());
va_start(ap, str);
vfprintf(logfile, str, ap);
fprintf(logfile, "\n" );
va_end(ap);
fflush(logfile);
}
fflush(stdout);
}

12
src/Client/log.h Normal file
View File

@ -0,0 +1,12 @@
#ifndef _LOG_H
#define _LOG_H
class PseuInstance;
void log_prepare(char *fn, PseuInstance* p);
void log(const char *str, ...);
void logdetail(const char *str, ...);
void logdebug(const char *str, ...);
#endif