Home  |  Blog Help Out  |  How-To Guides  |  Why Use Mozilla  |  About Jeremy

Extensions

Contact
Jeremy Gillick

Get Firefox!

ExtensionUninstaller API Technical Documentation

< BACK | INDEX | NEXT >

Logging

When the API uninstalls an application it autmatically logs its actions to the ExtUninstallLogger object. This object holds a hierarchal list of logs. This allows a process to have sub processes and to track where they go.

For example, one of the root log items could be "READ: application preferences", which could have child logs like "REMOVE: Preference domain 'myapp'". To display these logs you can either use the internal log dialog, via the API's showLogDialog(true) method, or you could list them yourself.

When you read the logs manually, you'll get the root log items ( ExtUninstallLogger object and each of them have a "children" array which contain any child logs.

When using a custom #uninstallFunc function, you'll need to log your activities. Below is an example of logging the actions of reading a datasource and then removing some elements from it.

1: function myapp_uninstall(oLogger, isTesting) { 2: 3: oLog = new ExtuninstallLogItem(oLogger.READ_ACTION, oLogger.SUCCESS_STATUS, "local.rdf"); 4: //Read local.rdf 5: try { 6: // ... 7: 8: //Remove from local.rdf 9: oChildLog = new ExtuninstallLogItem(oLogger.REMOVE_ACTION, oLogger.SUCCESS_STATUS, "element 'http://myapp.com/element/node/'"); 10: try { 11: // ... 12: } 13: catch(err2) { 14: oChildLog.status = oLogger.FAIL_STATUS; 15 oChildLog.errorCode = 1002; 16 oChildLog.errorMsg = err2; 17: } 18: oLog.addChild(oChildLog); 20: } 21: catch(err) { 22: oLog.status = oLogger.WARN_STATUS; 23: oLog.errorCode = 1001; 24: oLog.errorMsg = err; 25: } 26: oLogger.addLog(oLog); Line 1:

Initialize the function

Line 3:

Creates a log item assuming success.

Line 5 - 7

Your function read through local.rdf to get the elements you need to remove.

Line 9

Creates a child log item for the remove action, assuming success.

Line 10 - 12

Your code attempts to remove the datasource element.

Line 14 - 16

On failure, it sets the status, errorCode and errorMsg properties of the child log item to reflect the error.

Line 18

The child log item is added as a child to the main log item.

Line 22 - 24

On overall failuer, it sets the status, errorCode and errorMsg properties of the main log item to reflect the error.

Line 26

The main log item is added to the logger object.


< BACK | INDEX | NEXT >



Copyright © 2004 Jeremy Gillick, All rights reserved
All the content and code presented on this site is owned solely by Jeremy Gillick