Created
September 21, 2008 07:10
-
-
Save snj14/11848 to your computer and use it in GitHub Desktop.
log
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this function works on firefox extension. | |
function log(){ | |
const Ci = Components.interfaces; | |
const Cc = Components.classes; | |
function firebug(method, args){ | |
var windowManager = Cc['@mozilla.org/appshell/window-mediator;1'].getService(Ci.nsIWindowMediator); | |
var win = windowManager.getMostRecentWindow("navigator:browser"); | |
if(win.FirebugConsole && win.FirebugContext) { | |
var console = new win.FirebugConsole(win.FirebugContext, win.content); | |
console[method].apply(console, args); | |
} else if ( (win.Firebug || 0).Console ) { | |
// Firebug 1.2~ | |
win.Firebug.Console.logFormatted.call(win.Firebug.Console, Array.slice(args), win.FirebugContext, method); | |
} else { | |
return false; | |
} | |
return true; | |
} | |
function lognative(){ | |
const ConsoleService = Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService); | |
ConsoleService.logStringMessage(arguments); | |
} | |
firebug('log',arguments) || lognative(arguments); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment