fix mandatory client logfile

The logfile can't be created before the commandline arguments are parsed,
because before that, the home directory is unknown. This patch logs
into a memory buffer which is then copied to the logfile as soon as
the logfile is created after processing the commandline arguments.

The memory buffer is created during the initialisation of global variables,
and destroyed after the logfile is created.
This commit is contained in:
ac-stef
2014-10-06 12:43:32 +02:00
parent 8838972e83
commit 3bbe1f9555
5 changed files with 23 additions and 4 deletions
+2
View File
@@ -95,6 +95,7 @@ COMMANDN(toggleconsole, toggleconsole, "");
void renderconsole() { con.render(); }
stream *clientlogfile = NULL;
vector<char> *bootclientlog = new vector<char>;
int clientloglinesremaining = INT_MAX;
void clientlogf(const char *s, ...)
@@ -113,6 +114,7 @@ void clientlogf(const char *s, ...)
clientlogfile->printf("%s%s\n", ts, l);
if(--clientloglinesremaining <= 0) DELETEP(clientlogfile);
}
else if(bootclientlog) cvecprintf(*bootclientlog, "%s%s\n", ts, l);
l = p + 1;
}
while(p);