- added an errorlog option.

This cuts down on as much message noise as possible, outputs everything to a file specified as a parameter and then quits immediately, allowing this to run from a batch that's supposed to check a larger list of files for errors.
Multiple outputs get appended if the file already exists.
This commit is contained in:
Christoph Oelckers 2016-02-09 14:20:49 +01:00
parent 6c92525fcd
commit 4d2a52418f
22 changed files with 96 additions and 70 deletions

1
.gitignore vendored
View file

@ -40,3 +40,4 @@
/jpeg-6b/x64/
/lzma/x64/
/zlib/x64/
/build_vc2015

View file

@ -456,9 +456,9 @@ CCMD (exec)
}
}
void execLogfile(const char *fn)
void execLogfile(const char *fn, bool append)
{
if ((Logfile = fopen(fn, "w")))
if ((Logfile = fopen(fn, append? "a" : "w")))
{
const char *timestr = myasctime();
Printf("Log started: %s\n", timestr);
@ -482,7 +482,7 @@ CCMD (logfile)
if (argv.argc() >= 2)
{
execLogfile(argv[1]);
execLogfile(argv[1], argv.argc() >=3? !!argv[2]:false);
}
}

View file

@ -182,6 +182,6 @@ extern unsigned int MakeKey (const char *s);
extern unsigned int MakeKey (const char *s, size_t len);
extern unsigned int SuperFastHash (const char *data, size_t len);
void execLogfile(const char *fn);
void execLogfile(const char *fn, bool append = false);
#endif //__C_DISPATCH_H__

View file

@ -2495,7 +2495,7 @@ bool D_LoadDehFile(const char *patchfile)
static bool DoDehPatch()
{
Printf("Adding dehacked patch %s\n", PatchName);
if (!batchrun) Printf("Adding dehacked patch %s\n", PatchName);
int cont;
@ -2586,7 +2586,7 @@ static bool DoDehPatch()
UnloadDehSupp ();
delete[] PatchName;
delete[] PatchFile;
Printf ("Patch installed\n");
if (!batchrun) Printf ("Patch installed\n");
return true;
}

View file

@ -228,6 +228,7 @@ bool nospriterename;
FStartupInfo DoomStartupInfo;
FString lastIWAD;
int restart = 0;
bool batchrun; // just run the startup and collect all error messages in a logfile, then quit without any interaction
cycle_t FrameCycles;
@ -1868,7 +1869,6 @@ static FString ParseGameInfo(TArray<FString> &pwads, const char *fn, const char
static FString CheckGameInfo(TArray<FString> & pwads)
{
DWORD t = I_FPSTime();
// scan the list of WADs backwards to find the last one that contains a GAMEINFO lump
for(int i=pwads.Size()-1; i>=0; i--)
{
@ -1920,8 +1920,6 @@ static FString CheckGameInfo(TArray<FString> & pwads)
delete resfile;
}
}
t = I_FPSTime() - t;
Printf("Gameinfo scan took %d ms\n", t);
return "";
}
@ -2002,7 +2000,7 @@ static void D_DoomInit()
{
rngseed = staticrngseed = atoi(v);
use_staticrng = true;
Printf("D_DoomInit: Static RNGseed %d set.\n", rngseed);
if (!batchrun) Printf("D_DoomInit: Static RNGseed %d set.\n", rngseed);
}
else
{
@ -2012,7 +2010,7 @@ static void D_DoomInit()
FRandom::StaticClearRandom ();
Printf ("M_LoadDefaults: Load system defaults.\n");
if (!batchrun) Printf ("M_LoadDefaults: Load system defaults.\n");
M_LoadDefaults (); // load before initing other systems
}
@ -2080,7 +2078,7 @@ static void CheckCmdLine()
int p;
const char *v;
Printf ("Checking cmd-line parameters...\n");
if (!batchrun) Printf ("Checking cmd-line parameters...\n");
if (Args->CheckParm ("-nomonsters")) flags |= DF_NO_MONSTERS;
if (Args->CheckParm ("-respawn")) flags |= DF_MONSTERS_RESPAWN;
if (Args->CheckParm ("-fast")) flags |= DF_FAST_MONSTERS;
@ -2222,6 +2220,7 @@ void D_DoomMain (void)
FString *args;
int argcount;
FIWadManager *iwad_man;
const char *batchout = Args->CheckValue("-errorlog");
// +logfile gets checked too late to catch the full startup log in the logfile so do some extra check for it here.
FString logfile = Args->TakeValue("+logfile");
@ -2229,6 +2228,17 @@ void D_DoomMain (void)
{
execLogfile(logfile);
}
else if (batchout != NULL && *batchout != 0)
{
batchrun = true;
execLogfile(batchout, true);
Printf("Command line: ");
for (int i = 0; i < Args->NumArgs(); i++)
{
Printf("%s ", Args->GetArg(i));
}
Printf("\n");
}
if (Args->CheckParm("-hashfiles"))
{
@ -2339,7 +2349,7 @@ void D_DoomMain (void)
Printf("Notice: File hashing is incredibly verbose. Expect loading files to take much longer than usual.\n");
}
Printf ("W_Init: Init WADfiles.\n");
if (!batchrun) Printf ("W_Init: Init WADfiles.\n");
Wads.InitMultipleFiles (allwads);
allwads.Clear();
allwads.ShrinkToFit();
@ -2370,21 +2380,21 @@ void D_DoomMain (void)
if (!restart)
{
Printf ("I_Init: Setting up machine state.\n");
if (!batchrun) Printf ("I_Init: Setting up machine state.\n");
I_Init ();
I_CreateRenderer();
}
Printf ("V_Init: allocate screen.\n");
if (!batchrun) Printf ("V_Init: allocate screen.\n");
V_Init (!!restart);
// Base systems have been inited; enable cvar callbacks
FBaseCVar::EnableCallbacks ();
Printf ("S_Init: Setting up sound.\n");
if (!batchrun) Printf ("S_Init: Setting up sound.\n");
S_Init ();
Printf ("ST_Init: Init startup screen.\n");
if (!batchrun) Printf ("ST_Init: Init startup screen.\n");
if (!restart)
{
StartScreen = FStartupScreen::CreateInstance (TexMan.GuesstimateNumTextures() + 5);
@ -2402,23 +2412,23 @@ void D_DoomMain (void)
S_ParseReverbDef ();
// [RH] Parse any SNDINFO lumps
Printf ("S_InitData: Load sound definitions.\n");
if (!batchrun) Printf ("S_InitData: Load sound definitions.\n");
S_InitData ();
// [RH] Parse through all loaded mapinfo lumps
Printf ("G_ParseMapInfo: Load map definitions.\n");
if (!batchrun) Printf ("G_ParseMapInfo: Load map definitions.\n");
G_ParseMapInfo (iwad_info->MapInfo);
ReadStatistics();
// MUSINFO must be parsed after MAPINFO
S_ParseMusInfo();
Printf ("Texman.Init: Init texture manager.\n");
if (!batchrun) Printf ("Texman.Init: Init texture manager.\n");
TexMan.Init();
C_InitConback();
// [CW] Parse any TEAMINFO lumps.
Printf ("ParseTeamInfo: Load team definitions.\n");
if (!batchrun) Printf ("ParseTeamInfo: Load team definitions.\n");
TeamLibrary.ParseTeamInfo ();
PClassActor::StaticInit ();
@ -2437,11 +2447,11 @@ void D_DoomMain (void)
StartScreen->Progress ();
Printf ("R_Init: Init %s refresh subsystem.\n", gameinfo.ConfigName.GetChars());
if (!batchrun) Printf ("R_Init: Init %s refresh subsystem.\n", gameinfo.ConfigName.GetChars());
StartScreen->LoadingStatus ("Loading graphics", 0x3f);
R_Init ();
Printf ("DecalLibrary: Load decals.\n");
if (!batchrun) Printf ("DecalLibrary: Load decals.\n");
DecalLibrary.ReadAllDecals ();
// [RH] Add any .deh and .bex files on the command line.
@ -2458,7 +2468,7 @@ void D_DoomMain (void)
{
if (stricmp (key, "Path") == 0 && FileExists (value))
{
Printf ("Applying patch %s\n", value);
if (!batchrun) Printf ("Applying patch %s\n", value);
D_LoadDehFile(value);
}
}
@ -2483,10 +2493,10 @@ void D_DoomMain (void)
bglobal.spawn_tries = 0;
bglobal.wanted_botnum = bglobal.getspawned.Size();
Printf ("M_Init: Init menus.\n");
if (!batchrun) Printf ("M_Init: Init menus.\n");
M_Init ();
Printf ("P_Init: Init Playloop state.\n");
if (!batchrun) Printf ("P_Init: Init Playloop state.\n");
StartScreen->LoadingStatus ("Init game engine", 0x3f);
AM_StaticInit();
P_Init ();
@ -2497,22 +2507,25 @@ void D_DoomMain (void)
SBarInfo::Load();
HUD_InitHud();
// [RH] User-configurable startup strings. Because BOOM does.
static const char *startupString[5] = {
"STARTUP1", "STARTUP2", "STARTUP3", "STARTUP4", "STARTUP5"
};
for (p = 0; p < 5; ++p)
if (!batchrun)
{
const char *str = GStrings[startupString[p]];
if (str != NULL && str[0] != '\0')
// [RH] User-configurable startup strings. Because BOOM does.
static const char *startupString[5] = {
"STARTUP1", "STARTUP2", "STARTUP3", "STARTUP4", "STARTUP5"
};
for (p = 0; p < 5; ++p)
{
Printf ("%s\n", str);
const char *str = GStrings[startupString[p]];
if (str != NULL && str[0] != '\0')
{
Printf("%s\n", str);
}
}
}
if (!restart)
{
Printf ("D_CheckNetGame: Checking network game status.\n");
if (!batchrun) Printf ("D_CheckNetGame: Checking network game status.\n");
StartScreen->LoadingStatus ("Checking network game status.", 0x3f);
D_CheckNetGame ();
}
@ -2545,7 +2558,7 @@ void D_DoomMain (void)
StartScreen = NULL;
S_Sound (CHAN_BODY, "misc/startupdone", 1, ATTN_NONE);
if (Args->CheckParm("-norun"))
if (Args->CheckParm("-norun") || batchrun)
{
throw CNoRunExit();
}

View file

@ -1739,7 +1739,7 @@ void D_CheckNetGame (void)
Printf("Arbitrator selected " TEXTCOLOR_BLUE "%s" TEXTCOLOR_NORMAL " networking mode.\n", NetMode == NET_PeerToPeer ? "peer to peer" : "packet server");
}
Printf ("player %i of %i (%i nodes)\n",
if (!batchrun) Printf ("player %i of %i (%i nodes)\n",
consoleplayer+1, doomcom.numplayers, doomcom.numnodes);
}

View file

@ -125,6 +125,8 @@ typedef TMap<int, PClassActor *> FClassMap;
#include "basictypes.h"
extern bool batchrun;
// Bounding box coordinate storage.
enum
{

View file

@ -434,7 +434,7 @@ void SBarInfo::Load()
int lump = Wads.CheckNumForFullName(gameinfo.statusbar, true);
if(lump != -1)
{
Printf ("ParseSBarInfo: Loading default status bar definition.\n");
if (!batchrun) Printf ("ParseSBarInfo: Loading default status bar definition.\n");
if(SBarInfoScript[SCRIPT_DEFAULT] == NULL)
SBarInfoScript[SCRIPT_DEFAULT] = new SBarInfo(lump);
else
@ -444,7 +444,7 @@ void SBarInfo::Load()
if(Wads.CheckNumForName("SBARINFO") != -1)
{
Printf ("ParseSBarInfo: Loading custom status bar definition.\n");
if (!batchrun) Printf ("ParseSBarInfo: Loading custom status bar definition.\n");
int lastlump, lump;
lastlump = 0;
while((lump = Wads.FindLump("SBARINFO", &lastlump)) != -1)

View file

@ -152,7 +152,7 @@ void PClassActor::StaticInit()
sprites.Push (temp);
}
Printf ("LoadActors: Load actor definitions.\n");
if (!batchrun) Printf ("LoadActors: Load actor definitions.\n");
ClearStrifeTypes();
LoadActors ();
InitBotStuff();

View file

@ -55,11 +55,11 @@ bool UseKnownFolders()
if (file != INVALID_HANDLE_VALUE)
{
CloseHandle(file);
Printf("Using program directory for storage\n");
if (!batchrun) Printf("Using program directory for storage\n");
iswritable = true;
return false;
}
Printf("Using known folders for storage\n");
if (!batchrun) Printf("Using known folders for storage\n");
iswritable = false;
return true;
}

View file

@ -316,7 +316,7 @@ bool F7ZFile::Open(bool quiet)
}
}
if (!quiet) Printf(", %d lumps\n", NumLumps);
if (!quiet && !batchrun) Printf(", %d lumps\n", NumLumps);
PostProcessArchive(&Lumps[0], sizeof(F7ZLump));
return true;

View file

@ -121,7 +121,7 @@ bool FGrpFile::Open(bool quiet)
fileinfo[i].NameWithZero[12] = '\0'; // Be sure filename is null-terminated
Lumps[i].LumpNameSetup(fileinfo[i].NameWithZero);
}
if (!quiet) Printf(", %d lumps\n", NumLumps);
if (!quiet && !batchrun) Printf(", %d lumps\n", NumLumps);
delete[] fileinfo;
return true;

View file

@ -104,7 +104,7 @@ bool FPakFile::Open(bool quiet)
Lumps = new FUncompressedLump[NumLumps];
if (!quiet) Printf(", %d lumps\n", NumLumps);
if (!quiet && !batchrun) Printf(", %d lumps\n", NumLumps);
for(DWORD i = 0; i < NumLumps; i++)
{

View file

@ -152,7 +152,7 @@ bool FRFFFile::Open(bool quiet)
Lumps = new FRFFLump[NumLumps];
if (!quiet) Printf(", %d lumps\n", NumLumps);
if (!quiet && !batchrun) Printf(", %d lumps\n", NumLumps);
for (DWORD i = 0; i < NumLumps; ++i)
{
Lumps[i].Position = LittleLong(lumps[i].FilePos);

View file

@ -370,7 +370,7 @@ bool FWadFile::Open(bool quiet)
if (!quiet)
{
Printf(", %d lumps\n", NumLumps);
if (!batchrun) Printf(", %d lumps\n", NumLumps);
// don't bother with namespaces here. We won't need them.
SetNamespace("S_START", "S_END", ns_sprites);

View file

@ -268,7 +268,7 @@ bool FZipFile::Open(bool quiet)
NumLumps -= skipped;
free(directory);
if (!quiet) Printf(TEXTCOLOR_NORMAL ", %d lumps\n", NumLumps);
if (!quiet && !batchrun) Printf(TEXTCOLOR_NORMAL ", %d lumps\n", NumLumps);
PostProcessArchive(&Lumps[0], sizeof(FZipLump));
return true;

View file

@ -259,7 +259,7 @@ void I_InitSound ()
nosfx = !!Args->CheckParm ("-nosfx");
GSnd = NULL;
if (nosound)
if (nosound || batchrun)
{
GSnd = new NullSoundRenderer;
I_InitMusic ();

View file

@ -444,7 +444,7 @@ void LoadActors ()
}
FinishThingdef();
timer.Unclock();
Printf("DECORATE parsing took %.2f ms\n", timer.TimeMS());
if (!batchrun) Printf("DECORATE parsing took %.2f ms\n", timer.TimeMS());
// Base time: ~52 ms
}

View file

@ -256,7 +256,7 @@ void FWadCollection::AddFile (const char *filename, FileReader *wadinfo)
}
}
Printf (" adding %s", filename);
if (!batchrun) Printf (" adding %s", filename);
startlump = NumLumps;
FResourceFile *resfile;

View file

@ -1005,20 +1005,23 @@ void DoMain (HINSTANCE hInstance)
catch (class CNoRunExit &)
{
I_ShutdownGraphics();
if (FancyStdOut && !AttachedStdOut)
{ // Outputting to a new console window: Wait for a keypress before quitting.
DWORD bytes;
HANDLE stdinput = GetStdHandle(STD_INPUT_HANDLE);
ShowWindow (Window, SW_HIDE);
WriteFile(StdOut, "Press any key to exit...", 24, &bytes, NULL);
FlushConsoleInputBuffer(stdinput);
SetConsoleMode(stdinput, 0);
ReadConsole(stdinput, &bytes, 1, &bytes, NULL);
}
else if (StdOut == NULL)
if (!batchrun)
{
ShowErrorPane(NULL);
if (FancyStdOut && !AttachedStdOut)
{ // Outputting to a new console window: Wait for a keypress before quitting.
DWORD bytes;
HANDLE stdinput = GetStdHandle(STD_INPUT_HANDLE);
ShowWindow(Window, SW_HIDE);
WriteFile(StdOut, "Press any key to exit...", 24, &bytes, NULL);
FlushConsoleInputBuffer(stdinput);
SetConsoleMode(stdinput, 0);
ReadConsole(stdinput, &bytes, 1, &bytes, NULL);
}
else if (StdOut == NULL)
{
ShowErrorPane(NULL);
}
}
exit(0);
}
@ -1028,7 +1031,14 @@ void DoMain (HINSTANCE hInstance)
RestoreConView ();
if (error.GetMessage ())
{
ShowErrorPane (error.GetMessage());
if (!batchrun)
{
ShowErrorPane(error.GetMessage());
}
else
{
Printf("%s\n", error.GetMessage());
}
}
exit (-1);
}

View file

@ -595,14 +595,14 @@ void I_DetectOS(void)
if (OSPlatform == os_Win95)
{
Printf ("OS: Windows %s %lu.%lu.%lu %s\n",
if (!batchrun) Printf ("OS: Windows %s %lu.%lu.%lu %s\n",
osname,
info.dwMajorVersion, info.dwMinorVersion,
info.dwBuildNumber & 0xffff, info.szCSDVersion);
}
else
{
Printf ("OS: Windows %s (NT %lu.%lu) Build %lu\n %s\n",
if (!batchrun) Printf ("OS: Windows %s (NT %lu.%lu) Build %lu\n %s\n",
osname,
info.dwMajorVersion, info.dwMinorVersion,
info.dwBuildNumber, info.szCSDVersion);
@ -610,7 +610,7 @@ void I_DetectOS(void)
if (OSPlatform == os_unknown)
{
Printf ("(Assuming Windows 2000)\n");
if (!batchrun) Printf ("(Assuming Windows 2000)\n");
OSPlatform = os_Win2k;
}
}
@ -727,7 +727,7 @@ void CalculateCPUSpeed()
PerfToMillisec = PerfToSec * 1000.0;
}
Printf ("CPU Speed: %.0f MHz\n", 0.001 / PerfToMillisec);
if (!batchrun) Printf ("CPU Speed: %.0f MHz\n", 0.001 / PerfToMillisec);
}
//==========================================================================

View file

@ -195,7 +195,7 @@ void DumpCPUInfo(const CPUInfo *cpu)
}
*t = '\0';
if (cpu->VendorID[0])
if (cpu->VendorID[0] && !batchrun)
{
Printf("CPU Vendor ID: %s\n", cpu->VendorID);
if (cpustring[0])