Bug 1060171 - Part 1: Add log levels to nsIConsoleMessage. r=froydnj
authorEric Rahm <erahm@mozilla.com>
Mon, 22 Sep 2014 15:32:21 -0700
changeset 206599 6856ddce0f6e7010ebde314337027643c9fe1b5a
parent 206598 2c42e54473e29289a994f88dc04b20745aefc387
child 206600 0bd1b0fdba12dfc7cd3c1b7068baf3ac4be19be0
push idunknown
push userunknown
push dateunknown
reviewersfroydnj
bugs1060171
milestone35.0a1
Bug 1060171 - Part 1: Add log levels to nsIConsoleMessage. r=froydnj
js/xpconnect/idl/nsIScriptError.idl
js/xpconnect/src/nsScriptError.cpp
xpcom/base/nsConsoleMessage.cpp
xpcom/base/nsIConsoleMessage.idl
--- a/js/xpconnect/idl/nsIScriptError.idl
+++ b/js/xpconnect/idl/nsIScriptError.idl
@@ -6,17 +6,17 @@
 /*
  * nsIConsoleMessage subclass for representing JavaScript errors and warnings.
  */
 
 
 #include "nsISupports.idl"
 #include "nsIConsoleMessage.idl"
 
-[scriptable, uuid(cac9d8e8-0d53-4fa8-9903-bb367e4fa1fe)]
+[scriptable, uuid(d6a8dae2-367f-4939-a843-11e0c48e240c)]
 interface nsIScriptError : nsIConsoleMessage
 {
     /** pseudo-flag for default case */
     const unsigned long errorFlag = 0x0;
 
     /** message is warning */
     const unsigned long warningFlag = 0x1;
 
--- a/js/xpconnect/src/nsScriptError.cpp
+++ b/js/xpconnect/src/nsScriptError.cpp
@@ -47,16 +47,25 @@ nsScriptError::GetMessageMoz(char16_t **
 
     *result = UTF8ToNewUnicode(message);
     if (!*result)
         return NS_ERROR_OUT_OF_MEMORY;
 
     return NS_OK;
 }
 
+
+NS_IMETHODIMP
+nsScriptError::GetLogLevel(uint32_t* aLogLevel)
+{
+  *aLogLevel = mFlags & (uint32_t)nsIScriptError::errorFlag ?
+               nsIConsoleMessage::error : nsIConsoleMessage::warn;
+  return NS_OK;
+}
+
 // nsIScriptError methods
 NS_IMETHODIMP
 nsScriptError::GetErrorMessage(nsAString& aResult) {
     aResult.Assign(mMessage);
     return NS_OK;
 }
 
 NS_IMETHODIMP
--- a/xpcom/base/nsConsoleMessage.cpp
+++ b/xpcom/base/nsConsoleMessage.cpp
@@ -29,16 +29,23 @@ NS_IMETHODIMP
 nsConsoleMessage::GetMessageMoz(char16_t** aResult)
 {
   *aResult = ToNewUnicode(mMessage);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
+nsConsoleMessage::GetLogLevel(uint32_t* aLogLevel)
+{
+  *aLogLevel = nsConsoleMessage::info;
+  return NS_OK;
+}
+
+NS_IMETHODIMP
 nsConsoleMessage::GetTimeStamp(int64_t* aTimeStamp)
 {
   *aTimeStamp = mTimeStamp;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsConsoleMessage::ToString(nsACString& /*UTF8*/ aResult)
--- a/xpcom/base/nsIConsoleMessage.idl
+++ b/xpcom/base/nsIConsoleMessage.idl
@@ -5,19 +5,30 @@
 
 #include "nsISupports.idl"
 
 /**
  * This is intended as a base interface; implementations may want to
  * provide an object that can be qi'ed to provide more specific
  * message information.
  */
-[scriptable, uuid(c14c151b-5ea4-47ed-8e85-d392cdd3e154)]
+[scriptable, uuid(3aba9617-10e2-4839-83ae-2e6fc4df428b)]
 interface nsIConsoleMessage : nsISupports
 {
+    /** Log level constants. */
+    const uint32_t debug = 0;
+    const uint32_t info = 1;
+    const uint32_t warn = 2;
+    const uint32_t error = 3;
+
+    /**
+     * The log level of this message.
+     */
+    readonly attribute uint32_t logLevel;
+
     /**
      * The time (in milliseconds from the Epoch) that the message instance
      * was initialised.
      * The timestamp is initialized as JS_now/1000 so that it can be
      * compared to Date.now in Javascript.
      */
     readonly attribute long long timeStamp;