I have build an angularjs application. there are many places I used javascript console functions.
now I want to use a single variable to turn off those console.
I dont want to check the variable everytime whenever I use the console function.
so I decided to make a service to handle that process.
Console factory
AppModule
.factory("$console", function (ENV) {
function log (txt) {
var args = arguments;
if(ENV.debug) {
console.log.apply(this, args);
}
}
...
...
});
And I called that function like the following way.
Controller
AppModule
.controller('CommonCtrl', function ($scope, $console
$scope.personalInfo = function () {
$scope.errmsg = false;
getPersonalInfo(function (data) {
if(!$scope.errmsg) {
$console.log("userdatainfo:",data);
}
...
...
})
});
All is working perfectly. But Only the problem is I can only see the line number of the factory file on inspect panel. I need to have the line number from where the factory function is getting called (like the line no of the above controller file). Please reply with valuable suggestion.
console.trace()the same way like you did with thelog?