From MozillaZine Knowledge Base
Jump to navigationJump to search
|
|
(5 intermediate revisions by 2 users not shown) |
Line 1: |
Line 1: |
| You can output information to console using the following method:
| | #REDIRECT [[Error Console]] |
| | |
| *Declare global variable aConsoleService:
| |
| var aConsoleService;
| |
| *Initialize it [[Dev : Extensions : onLoad|on load]]:
| |
| aConsoleService = Components.classes['@mozilla.org/consoleservice;1'].getService(Components.interfaces.nsIConsoleService);
| |
| (note, you can also use toJavaScriptConsole() function to open JavaScript console on startup)
| |
| *Define a function:
| |
| function logMessage(message) {
| |
| aConsoleService.logStringMessage('MyApp: ' + message);
| |
| }
| |
| *Use it like here:
| |
| logMessage('Initialized.');
| |
| | |
| (thanks to clav, velcrospud and sage.mozdev.org for this)
| |
| | |
| See also: [[Dev : Tips : Enabling dump|Using dump()]]
| |
Latest revision as of 20:55, 30 April 2009