very basic file-based server logger (no syslog yet) / WIP

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@1941 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
driAn
2008-05-12 20:41:24 +00:00
parent 77fe513222
commit 9bb83edae7
9 changed files with 348 additions and 216 deletions
+54
View File
@@ -0,0 +1,54 @@
// server-side logging of events
#include "pch.h"
#include "cube.h"
struct filelog : log
{
FILE *file;
filelog(char *filepath)
{
file = fopen(filepath, "w");
}
~filelog()
{
if(file) fclose(file);
}
virtual void writeline(int level, char *msg, ...)
{
if(!enabled) return;
s_sprintfdv(sf, msg);
s_sprintfd(out)("%s\n", sf);
filtertext(out, out);
if(console)
{
puts(out);
fflush(stdout);
}
if(file)
{
fwrite(out, sizeof(char), strlen(out), file);
fflush(file);
}
}
};
struct syslog : log
{
virtual void writeline(int level, char *msg, ...)
{
}
};
struct log *newlogger()
{
return new filelog("serverlog.txt");
}