- added 'logfile' CCMD.

This commit is contained in:
Christoph Oelckers 2019-11-09 09:10:35 +01:00
parent 2997bb6292
commit 39df3d0560
2 changed files with 31 additions and 1 deletions

View file

@ -1 +0,0 @@

View file

@ -1064,3 +1064,34 @@ CCMD (exit)
{
throw ExitEvent(0);
}
extern FILE* Logfile;
void execLogfile(const char* fn, bool append)
{
if ((Logfile = fopen(fn, append ? "a" : "w")))
{
//const char* timestr = myasctime();
Printf("Log started\n");// , timestr);
}
else
{
Printf("Could not start log\n");
}
}
CCMD(logfile)
{
if (Logfile)
{
//const char* timestr = myasctime();
Printf("Log stopped: %s\n");// , timestr);
fclose(Logfile);
Logfile = NULL;
}
if (argv.argc() >= 2)
{
execLogfile(argv[1], argv.argc() >= 3 ? !!argv[2] : false);
}
}