Skip to content

Instantly share code, notes, and snippets.

View mksoni88's full-sized avatar

Mukesh Soni mksoni88

  • Bangalore, India
View GitHub Profile
@mksoni88
mksoni88 / overridelog.js
Created September 15, 2015 04:10
Override console.log to print line number ( and filename ) (sometimes helpful in nodejs debugging)
_log = console.log;
global.console.log = function() {
var traceobj = new Error("").stack.split("\n")[2].split(":");
var file = traceobj[0].split(process.env.PWD + '/')[1];
var line = traceobj[1];
var new_args = [file + ":" + line + " >>"];
new_args.push.apply(new_args, arguments);
_log.apply(null, new_args);
};