add static logs

This commit is contained in:
Glenn Maynard
2003-01-19 05:00:21 +00:00
parent ab9f558c6e
commit 861ba219c2
4 changed files with 56 additions and 2 deletions
+42 -2
View File
@@ -66,6 +66,7 @@ static VDDebugInfoContext g_debugInfo;
BOOL APIENTRY CrashDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
static void ReportCrashLog(HWND hwnd, HANDLE hFile);
static void ReportStaticLog(HWND hwnd, HANDLE hFile);
///////////////////////////////////////////////////////////////////////////
@@ -1357,6 +1358,9 @@ static void DoSave(const EXCEPTION_POINTERS *pExc) {
ReportCrashCallStack(NULL, hFile, pExc, g_pcdw->vdc.pExtraData);
Report(NULL, hFile, "");
ReportStaticLog(NULL, hFile);
Report(NULL, hFile, "");
ReportCrashLog(NULL, hFile);
Report(NULL, hFile, "");
@@ -1519,8 +1523,12 @@ static int backlog_start=0, backlog_cnt=0;
void CrashLog(const char *str)
{
strncpy(backlog[backlog_start], str, sizeof(backlog[backlog_start]));
backlog[backlog_start] [ sizeof(backlog[backlog_start])-1 ] = 0;
int len = strlen(str);
if(len > sizeof(backlog[backlog_start])-1)
len = sizeof(backlog[backlog_start])-1;
strncpy(backlog[backlog_start], str, len);
backlog[backlog_start] [ len ] = 0;
backlog_start++;
if(backlog_start > backlog_cnt)
@@ -1539,3 +1547,35 @@ static void ReportCrashLog(HWND hwnd, HANDLE hFile)
Report(hwnd, hFile, "%s", backlog[i]);
}
/* Same idea, except this is for data that we *always* want to print
* in the crash log, even if it was printed when we started. */
static const int STATICLOG_LINES = 100;
static char staticlog[BACKLOG_LINES][1024];
static int staticlog_cnt=0;
void StaticLog(const char *str)
{
if(staticlog_cnt == STATICLOG_LINES)
{
/* Use this sparingly! */
strcpy(staticlog[STATICLOG_LINES-1], "Staticlog limit reached");
return;
}
int len = strlen(str);
if(len > sizeof(staticlog[staticlog_cnt])-1)
len = sizeof(staticlog[staticlog_cnt])-1;
strncpy(staticlog[staticlog_cnt], str, len);
staticlog[staticlog_cnt] [ len ] = 0;
staticlog_cnt++;
}
static void ReportStaticLog(HWND hwnd, HANDLE hFile)
{
Report(NULL, hFile, "Static log:");
for(int i = 0; i < staticlog_cnt; ++i)
Report(hwnd, hFile, "%s", staticlog[i]);
}
+1
View File
@@ -53,6 +53,7 @@ void VirtualDubDeinitializeThread();
extern long __stdcall CrashHandler(struct _EXCEPTION_POINTERS *ExceptionInfo);
void CrashLog(const char *str);
void StaticLog(const char *str);
/* Exactly as advertised. (This will bring up the crash handler even
* in the debugger.) */
+12
View File
@@ -79,6 +79,18 @@ void RageLog::Trace( const char *fmt, ...)
#endif
}
/* Use this for more important information; it'll always be included
* in crash dumps. */
void RageLog::Info( const char *fmt, ...)
{
va_list va;
va_start(va, fmt);
CString sBuff = vssprintf( fmt, va );
va_end(va);
Trace("%s", sBuff);
StaticLog(sBuff);
}
void RageLog::Warn( const char *fmt, ...)
{
va_list va;
+1
View File
@@ -22,6 +22,7 @@ public:
void Trace( const char *fmt, ...);
void Warn( const char *fmt, ...);
void Info( const char *fmt, ...);
void Flush();
void ShowConsole();