Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Bogomil Shopov
committed
May 27, 2011
1 parent
8f2fbc8
commit 38b17aa
Showing
3 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
//define contstants | ||
const {Cu} = require("chrome"); | ||
|
||
//import LightweightThemeManager - the one responsible for handling Personas. | ||
const Iservices = Cu.import('resource://gre/modules/Services.jsm').Services; | ||
|
||
const econsole = Iservices.console; | ||
//define class element | ||
var JSimpleDebugger = | ||
{ | ||
//define function element | ||
write: function (args, callback) | ||
{ | ||
econsole.logStringMessage(args); | ||
}, | ||
dump: function(obj,level,callback) | ||
{ | ||
//based on http://binnyva.blogspot.com/2005/10/dump-function-javascript-equivalent-of.html | ||
var dumped_text = ""; | ||
if(!level) level = 0; | ||
|
||
//The padding given at the beginning of the line. | ||
var level_padding = ""; | ||
for(var j=0;j<level+1;j++) level_padding += " "; | ||
|
||
if(typeof(obj) == 'object') { | ||
for(var item in obj) { | ||
var value = obj[item]; | ||
|
||
if(typeof(value) == 'object') { | ||
dumped_text += level_padding + "'" + item + "' ...\n"; | ||
dumped_text += dump(value,level+1); | ||
} else { | ||
dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n"; | ||
} | ||
} | ||
} | ||
econsole.logStringMessage(dumped_text); | ||
|
||
|
||
} | ||
|
||
} | ||
//export object to be visible from your code | ||
exports.JSimpleDebugger = JSimpleDebugger; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
__About__ | ||
|
||
Using this Library you can actually put debug messages in your Firefox error console by calling 2 methods: | ||
1. .write (string) | ||
2. .dump(object) | ||
|
||
__Follow__ | ||
|
||
You can follow me on twitter: https://twitter.com/bogomep and identi.ca: http://identi.ca/bogomep | ||
|
||
|
||
__The License__ | ||
|
||
All files in this REPO are under this LICENSE: | ||
|
||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | ||
Version 2, December 2004 | ||
|
||
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net> | ||
|
||
Everyone is permitted to copy and distribute verbatim or modified | ||
copies of this license document, and changing it is allowed as long | ||
as the name is changed. | ||
|
||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | ||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | ||
|
||
0. You just DO WHAT THE FUCK YOU WANT TO. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
//import it | ||
const sd = require('JSimpleDebugger').JSimpleDebugger; | ||
|
||
|
||
//define an array | ||
var jarray = ['baba','kaka', 'tete']; | ||
|
||
//dump the object into console | ||
sd.dump(jarray); | ||
|
||
|
||
//define a string | ||
var jstring = "I love Open Web!"; | ||
|
||
//write a line of text | ||
sd.write(jstring); |