Bug 989691 - add nsContentUtils::LogMessageToConsole. r=jst

This commit is contained in:
Doug Turner 2014-04-01 10:52:37 -07:00
parent 6dad9aac30
commit d18a85ce28
2 changed files with 25 additions and 0 deletions

View File

@ -827,6 +827,8 @@ public:
uint32_t aLineNumber = 0,
uint32_t aColumnNumber = 0);
static void LogMessageToConsole(const char* aMsg, ...);
/**
* Get the localized string named |aKey| in properties file |aFile|.
*/

View File

@ -11,6 +11,7 @@
#include <algorithm>
#include <math.h>
#include "prprf.h"
#include "nsCxPusher.h"
#include "DecoderTraits.h"
#include "harfbuzz/hb.h"
@ -3149,6 +3150,28 @@ nsContentUtils::ReportToConsoleNonLocalized(const nsAString& aErrorText,
return sConsoleService->LogMessage(errorObject);
}
void
nsContentUtils::LogMessageToConsole(const char* aMsg, ...)
{
if (!sConsoleService) { // only need to bother null-checking here
CallGetService(NS_CONSOLESERVICE_CONTRACTID, &sConsoleService);
if (!sConsoleService) {
return;
}
}
va_list args;
va_start(args, aMsg);
char* formatted = PR_vsmprintf(aMsg, args);
va_end(args);
if (!formatted) {
return;
}
sConsoleService->LogStringMessage(NS_ConvertUTF8toUTF16(formatted).get());
PR_smprintf_free(formatted);
}
bool
nsContentUtils::IsChromeDoc(nsIDocument *aDocument)
{