33 #include <nsServiceManagerUtils.h>
34 #include <nsStringAPI.h>
38 #include <nsIConsoleService.h>
39 #include <nsIScriptError.h>
48 mMessage.Assign(aMessage);
56 NS_DECL_NSICONSOLEMESSAGE
67 *result = ToNewUnicode(mMessage);
75 nsAString const & aMessage,
76 nsAString const & aSource,
81 errorConsole->Log(nsDependentCString(aCategory),
82 nsIScriptError::errorFlag,
90 nsAString
const & aMessage,
91 nsAString
const & aSource,
96 errorConsole->Log(nsDependentCString(aCategory),
97 nsIScriptError::warningFlag,
109 va_start(args, aFmt);
110 char *
msg = PR_vsmprintf(aFmt, args);
111 errorConsole->Log(nsCString(),
113 NS_ConvertUTF8toUTF16(msg),
116 PR_smprintf_free(msg);
122 sbErrorConsole::Log(nsACString
const & aCategory,
124 nsAString
const & aMessage,
125 nsAString
const & aSource,
130 ErrorParams params(aFlags,
136 if (!NS_IsMainThread()) {
139 &sbErrorConsole::LogThread,
142 NS_ENSURE_SUCCESS(rv, rv);
145 rv = LogThread(params);
146 NS_ENSURE_SUCCESS(rv, rv);
152 nsresult sbErrorConsole::LogThread(ErrorParams aParameters)
156 nsCOMPtr<nsIConsoleService> consoleService =
157 do_GetService(
"@mozilla.org/consoleservice;1", &rv);
158 NS_ENSURE_SUCCESS (rv, rv);
160 nsCOMPtr<nsIConsoleMessage> consoleMessage;
161 if (aParameters.mFlags != infoMessageFlag) {
162 nsCOMPtr<nsIScriptError> scriptError =
163 do_CreateInstance(NS_SCRIPTERROR_CONTRACTID);
165 return NS_ERROR_FAILURE;
168 rv = scriptError->Init(aParameters.mMessage.get(),
169 aParameters.mSource.get(),
174 aParameters.mCategory.BeginReading());
175 NS_ENSURE_SUCCESS(rv,rv);
176 consoleMessage = scriptError;
181 rv = consoleService->LogMessage(consoleMessage);
182 NS_ENSURE_SUCCESS(rv,rv);
static void Warning(char const *aCategory, nsAString const &aMessage, nsAString const &aSource=nsString(), PRUint32 aLine=0)
NS_IMPL_THREADSAFE_ISUPPORTS1(sbDeviceCapsCompatibility, sbIDeviceCapsCompatibility) sbDeviceCapsCompatibility
static void Message(char const *aFmt,...)
void SetMessage(const nsAString &aMessage)
RT sbInvokeOnMainThread1(T &aObject, MT aMethod, RT aFailureReturnValue, A1 aArg1)
sbConsoleMessage(const nsAString &aMessage)