<div ng-app="app">
<div ng-controller="MainCtrl">
<h3>Make sure to open a javascript console so you can see the output.</h3>
</div>
</div>
JavaScript
angular.module('app', [])
.config(['$provide', function ($provide) {
$provide.decorator('$log', ['$delegate', function ($delegate) {
// Keep track of the original debug method, we'll need it later.
var origDebug = $delegate.debug;
/*
* Intercept the call to $log.debug() so we can add on
* our enhancement. We're going to add on a date and
* time stamp to the message that will be logged.
*/
$delegate.debug = function () {
var args = [].slice.call(arguments);
args[0] = [new Date().toString(), ': ', args[0]].join('');
// Send on our enhanced message to the original debug method.
origDebug.apply(null, args)
};
return $delegate;
}]);
}])
.controller('MainCtrl', ['$log', function ($log) {
$log.debug('Hello Debug!');
}]);
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.