Created
January 24, 2014 21:52
-
-
Save joelhooks/8607375 to your computer and use it in GitHub Desktop.
Enhanced Logging
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.run(function ($rootScope, $log, $window) { | |
var prepareLogFn = function (logFn) { | |
var enhancedLogFn = function () { | |
var modifiedArguments = Array.prototype.slice.call(arguments); | |
modifiedArguments[0] = [moment().format() + ' '] + modifiedArguments[0]; | |
logFn.apply(null, modifiedArguments); | |
}; | |
enhancedLogFn.logs = [ ]; | |
return enhancedLogFn; | |
}; | |
$log.log = prepareLogFn($log.log); | |
$log.info = prepareLogFn($log.info); | |
$log.warn = prepareLogFn($log.warn); | |
$log.debug = prepareLogFn($log.debug); | |
$log.error = prepareLogFn($log.error); | |
$rootScope.$log = $log; | |
$log.debug("Build Info:", $window.buildId); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment