forgot to add files
This commit is contained in:
parent
fa4385c74f
commit
f93fd5e246
84
src/Client/log.cpp
Normal file
84
src/Client/log.cpp
Normal 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
12
src/Client/log.h
Normal 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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user