-
Notifications
You must be signed in to change notification settings - Fork 8
12. Filter sensitive information from logs
lwhiteley edited this page Sep 22, 2014
·
3 revisions
You can set a list of keys to be filtered in objects before they are logged to the console.
NB. Only object
and array
will be processed for filtering
example.
app.config(['logExProvider', function(logExProvider) {
// this will extend the default configurations and enable the filtering of sensitive
// information for the specified keys.
logExProvider.configureLogFilters({
logFilters: ['password', 'card' ], // Default: [], result => ['password', 'card']
filterString: '[PRIVATE]' // Default: '[FILTERED]'
});
}]);
app.controller('MyCtrl2', function ($scope, $log) {
$log = $log.getInstance('MyCtrl2');
$log.log({password: '212eswds12', card: '213e213e2132132', name: 'John'});
});
will output:
September-14-2014-4:15:54PM::MyCtrl2 >> Object {password: '[PRIVATE]', card: '[PRIVATE]', name: 'John'}
AngularLogExtender | License: MIT | Made with 💚