I have the function Log which prints data along with passed arguments, how can I print the content & at the same time always print the word "Report: " at the beginning of the log.
function Log(){ if (app.debug_logs){ if(console && console.log){ console.log.apply(console, "Report: " + arguments); } } } Log(" error occurred ", " on this log... ");
I want to have: "Report: error occurred on this log..."
Thanks.
You can override the console.log
easily
(function(){ if(window.console && console.log){ var old = console.log; console.log = function(){ Array.prototype.unshift.call(arguments, 'Report: '); old.apply(this, arguments) } } })(); console.log('test')
Demo: Fiddle
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With