Skip to content

08. Override Log Prefix Log Prefix Formatter

lwhiteley edited this page Sep 22, 2014 · 1 revision

Add the logExProvider dependency to your AngularJS app to configure logging. Pass a custom function that accepts a className param to the overrideLogPrefix method

app.config(['logExProvider', function(logExProvider) {
    logExProvider.overrideLogPrefix(function (className) {
        var $injector = angular.injector([ 'ng' ]);
        var $filter = $injector.get( '$filter' );
        var separator = " >> ";
        var format = "MMMM-dd-yyyy-h:mm:ssa";
        var now = $filter('date')(new Date(), format);
        return "" + now + (!angular.isString(className) ? "" : "::" + className) + separator;
    });
}]);