add additional logging to diagnose 268245, sr=mscott

This commit is contained in:
bienvenu%nventure.com 2004-11-13 18:35:59 +00:00
parent 25396bfe1a
commit 0b8edec57d
2 changed files with 19 additions and 8 deletions

View File

@ -106,6 +106,6 @@ interface nsISpamSettings: nsISupports {
void ensureLogFile();
void flushLogIfNecessary();
void logJunkHit(in nsIMsgDBHdr aMsgHdr, in boolean aMoveMessage);
void logJunkString(in string aLogText);
void clone(in nsISpamSettings aSpamSettings);
};

View File

@ -474,10 +474,6 @@ NS_IMETHODIMP nsSpamSettings::LogJunkHit(nsIMsgDBHdr *aMsgHdr, PRBool aMoveMessa
if (!loggingEnabled)
return NS_OK;
nsCOMPtr <nsIOutputStream> logStream;
rv = GetLogStream(getter_AddRefs(logStream));
NS_ENSURE_SUCCESS(rv,rv);
PRTime date;
char dateStr[40]; /* 30 probably not enough */
@ -520,6 +516,22 @@ NS_IMETHODIMP nsSpamSettings::LogJunkHit(nsIMsgDBHdr *aMsgHdr, PRBool aMoveMessa
buffer += junkFolderURI.get();
buffer += "\n";
}
return LogJunkString(buffer.get());
}
NS_IMETHODIMP nsSpamSettings::LogJunkString(const char *string)
{
PRBool loggingEnabled;
nsresult rv = GetLoggingEnabled(&loggingEnabled);
NS_ENSURE_SUCCESS(rv,rv);
if (!loggingEnabled)
return NS_OK;
nsCOMPtr <nsIOutputStream> logStream;
rv = GetLogStream(getter_AddRefs(logStream));
NS_ENSURE_SUCCESS(rv,rv);
PRUint32 writeCount;
@ -530,13 +542,13 @@ NS_IMETHODIMP nsSpamSettings::LogJunkHit(nsIMsgDBHdr *aMsgHdr, PRBool aMoveMessa
// html escape the log for security reasons.
// we don't want some to send us a message with a subject with
// html tags, especially <script>
char *escapedBuffer = nsEscapeHTML(buffer.get());
char *escapedBuffer = nsEscapeHTML(string);
if (!escapedBuffer)
return NS_ERROR_OUT_OF_MEMORY;
PRUint32 escapedBufferLen = strlen(escapedBuffer);
rv = logStream->Write(escapedBuffer, escapedBufferLen, &writeCount);
PR_FREEIF(escapedBuffer);
PR_Free(escapedBuffer);
NS_ENSURE_SUCCESS(rv,rv);
NS_ASSERTION(writeCount == escapedBufferLen, "failed to write out log hit");
@ -546,7 +558,6 @@ NS_IMETHODIMP nsSpamSettings::LogJunkHit(nsIMsgDBHdr *aMsgHdr, PRBool aMoveMessa
return NS_OK;
}
NS_IMETHODIMP nsSpamSettings::OnStartRunningUrl(nsIURI* aURL)
{
// do nothing