added mandatory client log file

- a client will now write all os console messages to "clientlog.txt"
- at every game start, the log file gets rotated (with five old logs kept)
- commandline parameter "-N" can be used to limit the number of lines
  (after the lines are logged, the file is closed)
This commit is contained in:
ac-stef
2014-09-22 00:24:09 +02:00
parent 128e615ccc
commit fabfb73c83
3 changed files with 36 additions and 0 deletions
+8
View File
@@ -94,6 +94,9 @@ COMMANDN(toggleconsole, toggleconsole, "");
void renderconsole() { con.render(); }
stream *clientlogfile = NULL;
int clientloglinesremaining = INT_MAX;
void clientlogf(const char *s, ...)
{
defvformatstring(sp, s, s);
@@ -105,6 +108,11 @@ void clientlogf(const char *s, ...)
{ // break into single lines first
if((p = strchr(l, '\n'))) *p = '\0';
printf("%s%s\n", ts, l);
if(clientlogfile)
{
clientlogfile->printf("%s%s\n", ts, l);
if(--clientloglinesremaining <= 0) DELETEP(clientlogfile);
}
l = p + 1;
}
while(p);