improve this
This commit is contained in:
+22
-16
@@ -1555,33 +1555,39 @@ static void ReportCrashLog(HWND hwnd, HANDLE hFile)
|
|||||||
|
|
||||||
/* Same idea, except this is for data that we *always* want to print
|
/* 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. */
|
* in the crash log, even if it was printed when we started. */
|
||||||
static const int STATICLOG_LINES = 100;
|
static const int STATICLOG_SIZE = 1024*32;
|
||||||
static char staticlog[BACKLOG_LINES][1024];
|
static char staticlog[STATICLOG_SIZE];
|
||||||
static int staticlog_cnt=0;
|
static char *staticlog_ptr=staticlog, *staticlog_end=staticlog+STATICLOG_SIZE;
|
||||||
void StaticLog(const char *str)
|
void StaticLog(const char *str)
|
||||||
{
|
{
|
||||||
if(staticlog_cnt == STATICLOG_LINES)
|
if(!staticlog_ptr)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int len = strlen(str)+2; /* +newline +null */
|
||||||
|
if(staticlog_ptr+len >= staticlog_end)
|
||||||
{
|
{
|
||||||
/* Use this sparingly! */
|
const char *txt = "\nStaticlog limit reached\n";
|
||||||
strcpy(staticlog[STATICLOG_LINES-1], "Staticlog limit reached");
|
char *max_ptr = staticlog_end-strlen(txt)-1;
|
||||||
|
if(staticlog_ptr > max_ptr)
|
||||||
|
staticlog_ptr = max_ptr;
|
||||||
|
|
||||||
|
strcpy(staticlog_ptr, txt);
|
||||||
|
staticlog_ptr=NULL; /* stop */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int len = strlen(str);
|
strcpy(staticlog_ptr, str);
|
||||||
if(len > sizeof(staticlog[staticlog_cnt])-1)
|
|
||||||
len = sizeof(staticlog[staticlog_cnt])-1;
|
|
||||||
|
|
||||||
strncpy(staticlog[staticlog_cnt], str, len);
|
staticlog_ptr[len-2] = '\n';
|
||||||
staticlog[staticlog_cnt] [ len ] = 0;
|
staticlog_ptr[len-1] = 0;
|
||||||
|
/* Advance to sit on the NULL, so the terminator will be overwritten
|
||||||
staticlog_cnt++;
|
* on the next log. */
|
||||||
|
staticlog_ptr += len-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ReportStaticLog(HWND hwnd, HANDLE hFile)
|
static void ReportStaticLog(HWND hwnd, HANDLE hFile)
|
||||||
{
|
{
|
||||||
Report(NULL, hFile, "Static log:");
|
Report(NULL, hFile, "Static log:");
|
||||||
|
Report(hwnd, hFile, "%s", staticlog);
|
||||||
for(int i = 0; i < staticlog_cnt; ++i)
|
|
||||||
Report(hwnd, hFile, "%s", staticlog[i]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user