Changeset 4b9bc7


Ignore:
Timestamp:
Jan 26, 2015, 12:13:59 PM (7 years ago)
Author:
rene <rene@…>
Branches:
ng_0.9
Children:
d385a0
Parents:
b01bbc
Message:

made consolelogger more robust, added email-logger

File:
1 edited

Legend:

Unmodified
Added
Removed
  • modules/vI_log.js

    rb01bbc r4b9bc7  
    2525var EXPORTED_SYMBOLS = ["setupLogging", "dumpCallStack", "MyLog", "Colors",
    2626  "clearDebugOutput", "notificationOverflow",
    27   "SmartReplyNotification", "StorageNotification", "GetHeaderNotification"
     27  "SmartReplyNotification", "StorageNotification", "GetHeaderNotification", "errorReportEmail"
    2828]
    2929
     
    3737Cu.import("resource://v_identity/vI_prefs.js");
    3838Cu.import("resource://gre/modules/Services.jsm");
     39Cu.import("resource:///modules/mailServices.js");
    3940
    4041/** ******************************************************************************************************
     
    231232    root.addAppender(capp);
    232233
     234    dump("*** making ConsoleAppender robust against empty messages\n");
     235    // original implementation of doAppend dies if message data is empty
     236    capp.doAppend = function CApp_doAppend(message) {
     237      try {
     238        Services.console.logStringMessage(message);
     239      } catch (e) {}
     240    }
     241
    233242    // A dump appender outputs to standard out
    234243    let dapp = new Log4Moz.DumpAppender(myBasicFormatter);
     
    245254  return Log;
    246255}
     256
     257function errorReportEmail(e) {
     258  if (EmailReportAlreadyCreated) // do this only once per session, prevent endless loops
     259    return;
     260  EmailReportAlreadyCreated = true;
     261
     262  let params = Cc["@mozilla.org/messengercompose/composeparams;1"]
     263    .createInstance(Ci.nsIMsgComposeParams);
     264
     265  let composeFields = Cc["@mozilla.org/messengercompose/composefields;1"]
     266    .createInstance(Ci.nsIMsgCompFields);
     267
     268  let frame = (e && e.stack) ? e.stack : Components.stack;
     269
     270  let body =
     271    "# please send this debug-information if possible #\n" +
     272    "# it will help to make the extension better #\n" +
     273    "----------------------------------------------    \n" +
     274    "(even if some other message compose window does\n" +
     275    "not work anymore, sending this message might even\n" +
     276    "work with a virtual identity)\n" +
     277    "----------------------------------------------    \n\n\n" +
     278    "virtualIdentity raised an error: " + e + "\n\n";
     279  while (frame) {
     280    MyLog.debug(frame);
     281    body += frame + "\n";
     282    frame = frame.caller;
     283  }
     284
     285  let version = ""
     286  try {
     287    version = "*** " + Services.wm.getMostRecentWindow("msgcompose").document
     288      .getElementsByAttribute("class", "v_identity_logo v_identity_logo_statusbar")[0].value + " ***\n\n"
     289  } catch (e) {}
     290
     291  params.composeFields = composeFields;
     292  params.composeFields.subject = "Major Error in virtualIdentityExtension";
     293  params.composeFields.body = version + body;
     294  params.composeFields.to = "virtualIdentityBug@absorb.it";
     295
     296  MailServices.compose.OpenComposeWindowWithParams(null, params);
     297}
     298
    247299
    248300function dumpCallStack(e) {
     
    418470let GetHeaderNotification = Log4Moz.repository.getLogger("virtualIdentity.GetHeaderNotification");
    419471
     472let EmailReportAlreadyCreated = null;
     473
    420474UpdateSmartReplyNotification();
    421475UpdateStorageNotification();
Note: See TracChangeset for help on using the changeset viewer.