Skip to content

Commit

Permalink
Make console logging be enabled/disabled with log levels and scoped l…
Browse files Browse the repository at this point in the history
…oggers
  • Loading branch information
jwforres committed Mar 18, 2015
1 parent baa1569 commit 09154ef
Show file tree
Hide file tree
Showing 20 changed files with 502 additions and 413 deletions.
22 changes: 22 additions & 0 deletions assets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,28 @@ Contributing
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
```
#### Enable / disable console log output
Debug logging can be enabled by opening your browser's JavaScript console, running the commands below, and then refreshing the page.
```
localStorage["OpenShiftLogLevel.main"] = "<log level>";
localStorage["OpenShiftLogLevel.auth"] = "<log level>";
```
Loggers:
* `OpenShiftLogLevel.main` - default logger for OpenShift
* `OpenShiftLogLevel.auth` - auth specific logger, this includes login, logout, and oauth
The supported log levels are:
* OFF (default)
* INFO
* DEBUG
* WARN
* ERROR
Note: currently most of our logging either goes to INFO or ERROR
#### Before opening a pull request
1. If needed, run `hack/build-assets.sh` to update bindata.go
2. Run the test suite with `hack/test-assets.sh`
Expand Down
1 change: 1 addition & 0 deletions assets/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
<!-- build:js({.tmp,app}) scripts/scripts.js -->
<script src="scripts/app.js"></script>
<script src="scripts/misc/labelSelector.js"></script>
<script src="scripts/services/logger.js"></script>
<script src="scripts/services/ws.js"></script>
<script src="scripts/services/userstore.js"></script>
<script src="scripts/services/auth.js"></script>
Expand Down
6 changes: 3 additions & 3 deletions assets/app/scripts/controllers/builds.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Controller of the openshiftConsole
*/
angular.module('openshiftConsole')
.controller('BuildsController', function ($scope, DataService, $filter, LabelFilter) {
.controller('BuildsController', function ($scope, DataService, $filter, LabelFilter, Logger) {
$scope.builds = {};
$scope.unfilteredBuilds = {};
$scope.buildConfigs = {};
Expand Down Expand Up @@ -38,12 +38,12 @@ angular.module('openshiftConsole')
$scope.buildsByBuildConfig[buildConfigName][buildName] = build;
});

console.log("builds (subscribe)", $scope.unfilteredBuilds);
Logger.log("builds (subscribe)", $scope.unfilteredBuilds);
}));

watches.push(DataService.watch("buildConfigs", $scope, function(buildConfigs) {
$scope.buildConfigs = buildConfigs.by("metadata.name");
console.log("buildConfigs (subscribe)", $scope.buildConfigs);
Logger.log("buildConfigs (subscribe)", $scope.buildConfigs);
}));

var updateFilterWarning = function() {
Expand Down
8 changes: 4 additions & 4 deletions assets/app/scripts/controllers/catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Controller of the openshiftConsole
*/
angular.module('openshiftConsole')
.controller('CatalogController', function ($scope, DataService, $filter, LabelFilter) {
.controller('CatalogController', function ($scope, DataService, $filter, LabelFilter, Logger) {
$scope.projectTemplates = {};
$scope.openshiftTemplates = {};

Expand All @@ -21,14 +21,14 @@ angular.module('openshiftConsole')
$scope.projectTemplates = templates.by("metadata.name");
allTemplates();
templatesByTag();
console.log("project templates", $scope.projectTemplates);
Logger.log("project templates", $scope.projectTemplates);
});

DataService.list("templates", {namespace: "openshift"}, function(templates) {
$scope.openshiftTemplates = templates.by("metadata.name");
allTemplates();
templatesByTag();
console.log("openshift templates", $scope.openshiftTemplates);
Logger.log("openshift templates", $scope.openshiftTemplates);
});

var allTemplates = function() {
Expand All @@ -55,6 +55,6 @@ angular.module('openshiftConsole')
}
});

console.log("templatesByTag", $scope.templatesByTag);
Logger.log("templatesByTag", $scope.templatesByTag);
};
});
10 changes: 5 additions & 5 deletions assets/app/scripts/controllers/deployments.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Controller of the openshiftConsole
*/
angular.module('openshiftConsole')
.controller('DeploymentsController', function ($scope, DataService, $filter, LabelFilter) {
.controller('DeploymentsController', function ($scope, DataService, $filter, LabelFilter, Logger) {
$scope.deployments = {};
$scope.unfilteredDeployments = {};
$scope.images = {};
Expand All @@ -26,20 +26,20 @@ angular.module('openshiftConsole')
$scope.deployments = LabelFilter.getLabelSelector().select($scope.unfilteredDeployments);
$scope.emptyMessage = "No deployments to show";
updateFilterWarning();
console.log("deployments (subscribe)", $scope.deployments);
Logger.log("deployments (subscribe)", $scope.deployments);
}));

// Also load images and builds to fill out details in the pod template
watches.push(DataService.watch("images", $scope, function(images) {
$scope.images = images.by("metadata.name");
$scope.imagesByDockerReference = images.by("dockerImageReference");
console.log("images (subscribe)", $scope.images);
console.log("imagesByDockerReference (subscribe)", $scope.imagesByDockerReference);
Logger.log("images (subscribe)", $scope.images);
Logger.log("imagesByDockerReference (subscribe)", $scope.imagesByDockerReference);
}));

watches.push(DataService.watch("builds", $scope, function(builds) {
$scope.builds = builds.by("metadata.name");
console.log("builds (subscribe)", $scope.builds);
Logger.log("builds (subscribe)", $scope.builds);
}));

var updateFilterWarning = function() {
Expand Down
6 changes: 3 additions & 3 deletions assets/app/scripts/controllers/images.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Controller of the openshiftConsole
*/
angular.module('openshiftConsole')
.controller('ImagesController', function ($scope, DataService, $filter, LabelFilter) {
.controller('ImagesController', function ($scope, DataService, $filter, LabelFilter, Logger) {
$scope.images = {};
$scope.unfilteredImages = {};
$scope.builds = {};
Expand All @@ -24,13 +24,13 @@ angular.module('openshiftConsole')
$scope.images = LabelFilter.getLabelSelector().select($scope.unfilteredImages);
$scope.emptyMessage = "No images to show";
updateFilterWarning();
console.log("images (subscribe)", $scope.images);
Logger.log("images (subscribe)", $scope.images);
}));

// Also load builds so we can link out to builds associated with images
watches.push(DataService.watch("builds", $scope, function(builds) {
$scope.builds = builds.by("metadata.name");
console.log("builds (subscribe)", $scope.builds);
Logger.log("builds (subscribe)", $scope.builds);
}));

var updateFilterWarning = function() {
Expand Down
24 changes: 12 additions & 12 deletions assets/app/scripts/controllers/overview.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Controller of the openshiftConsole
*/
angular.module('openshiftConsole')
.controller('OverviewController', function ($scope, DataService, $filter, LabelFilter) {
.controller('OverviewController', function ($scope, DataService, $filter, LabelFilter, Logger) {
$scope.pods = {};
$scope.services = {};
$scope.unfilteredServices = {};
Expand Down Expand Up @@ -45,7 +45,7 @@ angular.module('openshiftConsole')
watches.push(DataService.watch("pods", $scope, function(pods) {
$scope.pods = pods.by("metadata.name");
podRelationships();
console.log("pods", $scope.pods);
Logger.log("pods", $scope.pods);
}, {poll: true}));

watches.push(DataService.watch("services", $scope, function(services) {
Expand All @@ -61,7 +61,7 @@ angular.module('openshiftConsole')

$scope.emptyMessage = "No services to show";
updateFilterWarning();
console.log("services (list)", $scope.services);
Logger.log("services (list)", $scope.services);
}));

// Expects deploymentsByServiceByDeploymentConfig to be up to date
Expand Down Expand Up @@ -115,9 +115,9 @@ angular.module('openshiftConsole')
}
});

console.log("podsByDeployment", $scope.podsByDeployment);
console.log("podsByService", $scope.podsByService);
console.log("monopodsByService", $scope.monopodsByService);
Logger.log("podsByDeployment", $scope.podsByDeployment);
Logger.log("podsByService", $scope.podsByService);
Logger.log("monopodsByService", $scope.monopodsByService);
};

// Filter out monopods we know we don't want to see
Expand Down Expand Up @@ -206,7 +206,7 @@ angular.module('openshiftConsole')
deployment.details = depConfig.details;
}
catch (e) {
console.log("Failed to parse encoded deployment config", e);
Logger.error("Failed to parse encoded deployment config", e);
}
}
}
Expand All @@ -228,15 +228,15 @@ angular.module('openshiftConsole')
// Order is important here since podRelationships expects deploymentsByServiceByDeploymentConfig to be up to date
deploymentsByService();
podRelationships();
console.log("deployments (subscribe)", $scope.deployments);
Logger.log("deployments (subscribe)", $scope.deployments);
}));

// Sets up subscription for images and imagesByDockerReference
watches.push(DataService.watch("images", $scope, function(images) {
$scope.images = images.by("metadata.name");
$scope.imagesByDockerReference = images.by("dockerImageReference");
console.log("images (subscribe)", $scope.images);
console.log("imagesByDockerReference (subscribe)", $scope.imagesByDockerReference);
Logger.log("images (subscribe)", $scope.images);
Logger.log("imagesByDockerReference (subscribe)", $scope.imagesByDockerReference);
}));


Expand Down Expand Up @@ -294,7 +294,7 @@ angular.module('openshiftConsole')

deploymentConfigsByService();

console.log("deploymentConfigs (subscribe)", $scope.deploymentConfigs);
Logger.log("deploymentConfigs (subscribe)", $scope.deploymentConfigs);
}));

// Sets up subscription for builds, associates builds to triggers on deploymentConfigs
Expand All @@ -315,7 +315,7 @@ angular.module('openshiftConsole')
else if (action === 'DELETED'){
// TODO
}
console.log("builds (subscribe)", $scope.builds);
Logger.log("builds (subscribe)", $scope.builds);
}));

var updateFilterWarning = function() {
Expand Down
10 changes: 5 additions & 5 deletions assets/app/scripts/controllers/pods.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Controller of the openshiftConsole
*/
angular.module('openshiftConsole')
.controller('PodsController', function ($scope, DataService, $filter, LabelFilter) {
.controller('PodsController', function ($scope, DataService, $filter, LabelFilter, Logger) {
$scope.pods = {};
$scope.unfilteredPods = {};
$scope.images = {};
Expand All @@ -26,20 +26,20 @@ angular.module('openshiftConsole')
$scope.pods = LabelFilter.getLabelSelector().select($scope.unfilteredPods);
$scope.emptyMessage = "No pods to show";
updateFilterWarning();
console.log("pods (subscribe)", $scope.unfilteredPods);
Logger.log("pods (subscribe)", $scope.unfilteredPods);
}));

// Also load images and builds to fill out details in the pod template
watches.push(DataService.watch("images", $scope, function(images) {
$scope.images = images.by("metadata.name");
$scope.imagesByDockerReference = images.by("dockerImageReference");
console.log("images (subscribe)", $scope.images);
console.log("imagesByDockerReference (subscribe)", $scope.imagesByDockerReference);
Logger.log("images (subscribe)", $scope.images);
Logger.log("imagesByDockerReference (subscribe)", $scope.imagesByDockerReference);
}));

watches.push(DataService.watch("builds", $scope, function(builds) {
$scope.builds = builds.by("metadata.name");
console.log("builds (subscribe)", $scope.builds);
Logger.log("builds (subscribe)", $scope.builds);
}));

var updateFilterWarning = function() {
Expand Down
4 changes: 2 additions & 2 deletions assets/app/scripts/controllers/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Controller of the openshiftConsole
*/
angular.module('openshiftConsole')
.controller('ProjectController', function ($scope, $routeParams, DataService, AuthService, $filter, LabelFilter, $location) {
.controller('ProjectController', function ($scope, $routeParams, DataService, AuthService, $filter, LabelFilter, $location, Logger) {

$scope.projectName = $routeParams.project;
$scope.project = {};
Expand Down Expand Up @@ -52,7 +52,7 @@ angular.module('openshiftConsole')

DataService.list("projects", $scope, function(projects) {
$scope.projects = projects.by("metadata.name");
console.log("projects", $scope.projects);
Logger.log("projects", $scope.projects);
});

});
Expand Down
6 changes: 3 additions & 3 deletions assets/app/scripts/controllers/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Controller of the openshiftConsole
*/
angular.module('openshiftConsole')
.controller('ServicesController', function ($scope, DataService, $filter, LabelFilter) {
.controller('ServicesController', function ($scope, DataService, $filter, LabelFilter, Logger) {
$scope.services = {};
$scope.unfilteredServices = {};
$scope.routesByService = {};
Expand All @@ -24,12 +24,12 @@ angular.module('openshiftConsole')
$scope.services = LabelFilter.getLabelSelector().select($scope.unfilteredServices);
$scope.emptyMessage = "No services to show";
updateFilterWarning();
console.log("services (subscribe)", $scope.unfilteredServices);
Logger.log("services (subscribe)", $scope.unfilteredServices);
}));

watches.push(DataService.watch("routes", $scope, function(routes){
$scope.routesByService = routesByService(routes.by("metadata.name"));
console.log("routes (subscribe)", $scope.routesByService);
Logger.log("routes (subscribe)", $scope.routesByService);
}));

var routesByService = function(routes) {
Expand Down
6 changes: 3 additions & 3 deletions assets/app/scripts/controllers/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Controller of the openshiftConsole
*/
angular.module('openshiftConsole')
.controller('SettingsController', function ($scope, DataService, $filter, LabelFilter, $timeout) {
.controller('SettingsController', function ($scope, DataService, $filter, LabelFilter, $timeout, Logger) {
$scope.quotas = {};
$scope.limitRanges = {};
$scope.labelSuggestions = {};
Expand All @@ -22,7 +22,7 @@ angular.module('openshiftConsole')
DataService.list("resourcequotas", $scope, function(quotas) {
$scope.quotas = quotas.by("metadata.name");
$scope.emptyMessageQuotas = "There are no resource quotas set on this project.";
console.log("quotas", $scope.quotas);
Logger.log("quotas", $scope.quotas);
});

DataService.list("limitranges", $scope, function(limitRanges) {
Expand All @@ -42,7 +42,7 @@ angular.module('openshiftConsole')
});
});
});
console.log("limitRanges", $scope.limitRanges);
Logger.log("limitRanges", $scope.limitRanges);
});

$scope.$on('$destroy', function(){
Expand Down
Loading

0 comments on commit 09154ef

Please sign in to comment.