Last active
October 13, 2015 14:40
-
-
Save rokerkony/09f20117a78516560b59 to your computer and use it in GitHub Desktop.
log provider disabled on prod - WIP - not working ...
This file contains 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
namespace SellerCenterExpress { | |
'use strict'; | |
/** | |
* @ngdoc function | |
* @name scxApp.config:LogProvider | |
* @description | |
* # logConfiguration | |
*/ | |
class LogProvider { | |
static $inject: string[] = [ | |
'$provide', | |
]; | |
constructor ($provide: ng.auto.IProvideService) { | |
$provide.decorator( | |
'$log', | |
[ | |
'$delegate', | |
function ($delegate) { | |
console.log('aaaa'); | |
let enabled = false; | |
let $log = { | |
debugEnabled: function(flag) { | |
console.log('flag', flag); | |
console.log('flag1', !flag); | |
console.log('flag2', !!flag); | |
enabled = !!flag; | |
} | |
}; | |
// methods implemented by Angular's $log service | |
['log', 'warn', 'info', 'error'].forEach(function(methodName) { | |
console.log('b', methodName); | |
$log[methodName] = function() { | |
console.log('c', methodName); | |
console.log('enabled', enabled); | |
if (enabled) { | |
console.log('$delegate', $delegate); | |
let logger = $delegate; | |
logger[methodName].apply(logger, arguments); | |
} | |
console.log('d', methodName); | |
}; | |
}); | |
return $log; | |
} | |
] | |
); | |
} | |
} | |
/** | |
* @ngdoc function | |
* @name scxApp.config:LogProvider | |
* @description | |
* # logConfiguration | |
*/ | |
class LogProviderDev { | |
static $inject: string[] = [ | |
'$logProvider', | |
]; | |
constructor ($logProvider: ng.ILogProvider) { | |
$logProvider.debugEnabled(true); | |
} | |
} | |
scxApp.config(LogProvider); | |
scxAppDev.config(LogProviderDev); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment