Skip to content

Instantly share code, notes, and snippets.

@lemnis
Created October 20, 2015 21:40
Show Gist options
  • Save lemnis/b6112c592095b0755971 to your computer and use it in GitHub Desktop.
Save lemnis/b6112c592095b0755971 to your computer and use it in GitHub Desktop.
Extended debug for sketch
var debug = {
getCallstack: function(){
var err = (new Error),
caller_stack = err.stack.split("\n"),
stack = [];
for (var i = 0; i < caller_stack.length; i++) {
var caller = caller_stack[i],
caller_line = caller.split(":"),
caller_nf = caller_line[0].split("@"),
caller_name = caller_nf[0],
caller_file = caller_nf[1].split("/");
stack.push({
file: caller_file[caller_file.length - 1],
name: caller_name,
line: caller_line[2],
column: caller_line[1]
});
};
return stack;
},
log: function(message){
var callee = this.getCallstack()[1];
log("## Func: " + callee.name + " ## " + callee.file + ":"+ callee.line + ":" + callee.column );
log(message);
},
dump: function(obj){
log("#####################################################################################")
log("## Dumping object " + obj )
log("## obj class is: " + [obj className])
log("#####################################################################################")
log("obj.properties:")
log([obj class].mocha().properties())
log("obj.propertiesWithAncestors:")
log([obj class].mocha().propertiesWithAncestors())
log("obj.classMethods:")
log([obj class].mocha().classMethods())
log("obj.classMethodsWithAncestors:")
log([obj class].mocha().classMethodsWithAncestors())
log("obj.instanceMethods:")
log([obj class].mocha().instanceMethods())
log("obj.instanceMethodsWithAncestors:")
log([obj class].mocha().instanceMethodsWithAncestors())
log("obj.protocols:")
log([obj class].mocha().protocols())
log("obj.protocolsWithAncestors:")
log([obj class].mocha().protocolsWithAncestors())
log("obj.treeAsDictionary():")
log(obj.treeAsDictionary())
}
}
@lemnis
Copy link
Author

lemnis commented Oct 20, 2015

Thanks to dunckr for the dump func
https://gist.github.com/dunckr/48f3168ca88c5df5e3cc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment