Skip to content
Snippets Groups Projects
Commit 23b07625 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Lower severity of repeated error messages in js_ErrorReporter()

A copy/paste from websrvr.c
parent 39b96453
No related branches found
No related tags found
No related merge requests found
...@@ -640,10 +640,10 @@ js_ErrorReporter(JSContext *cx, const char *message, JSErrorReport *report) ...@@ -640,10 +640,10 @@ js_ErrorReporter(JSContext *cx, const char *message, JSErrorReport *report)
char file[MAX_PATH+1]; char file[MAX_PATH+1];
char* prot="???"; char* prot="???";
SOCKET sock=0; SOCKET sock=0;
char* warning; char* warning = "";
service_client_t* client; service_client_t* client;
jsrefcount rc; jsrefcount rc;
int log_level; int log_level = LOG_ERR;
if((client=(service_client_t*)JS_GetContextPrivate(cx))!=NULL) { if((client=(service_client_t*)JS_GetContextPrivate(cx))!=NULL) {
prot=client->service->protocol; prot=client->service->protocol;
...@@ -673,9 +673,21 @@ js_ErrorReporter(JSContext *cx, const char *message, JSErrorReport *report) ...@@ -673,9 +673,21 @@ js_ErrorReporter(JSContext *cx, const char *message, JSErrorReport *report)
else else
warning="warning"; warning="warning";
log_level=LOG_WARNING; log_level=LOG_WARNING;
} else { } else if(report->filename != NULL) {
log_level=LOG_ERR; static pthread_mutex_t mutex;
warning=""; static bool mutex_initialized;
static char lastfile[MAX_PATH + 1];
static uint lastline;
if(!mutex_initialized) {
pthread_mutex_init(&mutex,NULL);
mutex_initialized = true;
}
pthread_mutex_lock(&mutex);
if(lastline == report->lineno && strcmp(lastfile, report->filename) == 0)
log_level = LOG_WARNING;
lastline = report->lineno;
SAFECOPY(lastfile, report->filename);
pthread_mutex_unlock(&mutex);
} }
rc=JS_SUSPENDREQUEST(cx); rc=JS_SUSPENDREQUEST(cx);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment