Merge pull request #6417 from ajp8164/feat/improved-log
Enhance logging with timestamps and filtering.
This commit is contained in:
commit
e2cd5650ed
14 changed files with 356 additions and 47 deletions
|
|
@ -1,39 +1,73 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('preferencesLogs',
|
||||
function($scope, historicLog, platformInfo) {
|
||||
function($scope, historicLog, lodash, configService, gettextCatalog) {
|
||||
|
||||
var config = configService.getSync();
|
||||
var logLevels = historicLog.getLevels();
|
||||
var selectedLevel;
|
||||
|
||||
$scope.logOptions = lodash.indexBy(logLevels, 'level');
|
||||
|
||||
var filterLogs = function(weight) {
|
||||
$scope.filteredLogs = historicLog.get(weight);
|
||||
};
|
||||
|
||||
$scope.setOptionSelected = function(level) {
|
||||
var weight = $scope.logOptions[level].weight;
|
||||
$scope.fillClass = 'fill-bar-' + level;
|
||||
filterLogs(weight);
|
||||
lodash.each($scope.logOptions, function(opt) {
|
||||
opt.selected = opt.weight <= weight ? true : false;
|
||||
opt.head = opt.weight == weight;
|
||||
});
|
||||
|
||||
// Save the setting.
|
||||
var opts = {
|
||||
log: {
|
||||
filter: level
|
||||
}
|
||||
};
|
||||
configService.set(opts, function(err) {
|
||||
if (err) $log.debug(err);
|
||||
});
|
||||
};
|
||||
|
||||
$scope.prepareLogs = function() {
|
||||
var log = 'Copay Session Logs\n Be careful, this could contain sensitive private data\n\n';
|
||||
log += '\n\n';
|
||||
log += historicLog.get().map(function(v) {
|
||||
return '[' + v.timestamp + '][' + v.level + ']' + v.msg;
|
||||
}).join('\n');
|
||||
|
||||
return log;
|
||||
};
|
||||
|
||||
$scope.sendLogs = function() {
|
||||
var body = $scope.prepareLogs();
|
||||
|
||||
window.plugins.socialsharing.shareViaEmail(
|
||||
body,
|
||||
'Copay Logs',
|
||||
null, // TO: must be null or an array
|
||||
null, // CC: must be null or an array
|
||||
null, // BCC: must be null or an array
|
||||
null, // FILES: can be null, a string, or an array
|
||||
function() {},
|
||||
function() {}
|
||||
);
|
||||
};
|
||||
|
||||
$scope.showOptionsMenu = function() {
|
||||
$scope.showOptions = true;
|
||||
};
|
||||
|
||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||
$scope.isCordova = platformInfo.isCordova;
|
||||
selectedLevel = lodash.has(config, 'log.filter') ? historicLog.getLevel(config.log.filter) : historicLog.getDefaultLevel();
|
||||
$scope.setOptionSelected(selectedLevel.level);
|
||||
});
|
||||
|
||||
$scope.$on("$ionicView.enter", function(event, data) {
|
||||
$scope.logs = historicLog.get();
|
||||
|
||||
$scope.prepare = function() {
|
||||
var log = 'Copay Session Logs\n Be careful, this could contain sensitive private data\n\n';
|
||||
log += '\n\n';
|
||||
log += $scope.logs.map(function(v) {
|
||||
return v.msg;
|
||||
}).join('\n');
|
||||
|
||||
return log;
|
||||
};
|
||||
|
||||
$scope.sendLogs = function() {
|
||||
var body = $scope.prepare();
|
||||
|
||||
window.plugins.socialsharing.shareViaEmail(
|
||||
body,
|
||||
'Copay Logs',
|
||||
null, // TO: must be null or an array
|
||||
null, // CC: must be null or an array
|
||||
null, // BCC: must be null or an array
|
||||
null, // FILES: can be null, a string, or an array
|
||||
function() {},
|
||||
function() {}
|
||||
);
|
||||
};
|
||||
|
||||
filterLogs(selectedLevel.weight);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue