Skip to content

Commit

Permalink
Adjust default log levels for web console and log errors when the loc…
Browse files Browse the repository at this point in the history
…al storage user store is unavailable
  • Loading branch information
jwforres committed Apr 2, 2015
1 parent c6ea692 commit 48fb92a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
4 changes: 2 additions & 2 deletions assets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ Loggers:
* `OpenShiftLogLevel.auth` - auth specific logger, this includes login, logout, and oauth
The supported log levels are:
* OFF (default)
* OFF (default for all loggers except main)
* INFO
* DEBUG
* WARN
* ERROR
* ERROR (default for main)
Note: currently most of our logging either goes to INFO or ERROR
Expand Down
3 changes: 3 additions & 0 deletions assets/app/scripts/services/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ angular.module('openshiftConsole')
var _logoutPromise = null;

var userStore = loadService($injector, _userStore, "AuthServiceProvider.UserStore()");
if (!userStore.available()) {
Logger.error("AuthServiceProvider.$get user store " + _userStore + " not available");
}
var loginService = loadService($injector, _loginService, "AuthServiceProvider.LoginService()");
var logoutService = loadService($injector, _logoutService, "AuthServiceProvider.LogoutService()");

Expand Down
12 changes: 10 additions & 2 deletions assets/app/scripts/services/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ angular.module('openshiftConsole')
var logger = {
get: function(name) {
var logger = Logger.get("OpenShift/" + name);
logger.setLevel(Logger[localStorage['OpenShiftLogLevel.' + name] || "OFF"]);
var logLevel = "OFF";
if (localStorage) {
logLevel = localStorage['OpenShiftLogLevel.' + name] || logLevel;
}
logger.setLevel(Logger[logLevel]);
return logger;
},
log: function() {
Expand All @@ -29,7 +33,11 @@ angular.module('openshiftConsole')
};

// Set default log level
OSLogger.setLevel(Logger[localStorage['OpenShiftLogLevel.main'] || "OFF"]);
var logLevel = "ERROR";
if (localStorage) {
logLevel = localStorage['OpenShiftLogLevel.main'] || logLevel;
}
OSLogger.setLevel(Logger[logLevel]);
return logger;
};
});
12 changes: 7 additions & 5 deletions pkg/assets/bindata.go
Original file line number Diff line number Diff line change
Expand Up @@ -12713,8 +12713,8 @@ return c($(this).attr("data-timestamp")) || b;
this.$get = function() {
var a = Logger.get("OpenShift"), b = {
get:function(a) {
var b = Logger.get("OpenShift/" + a);
return b.setLevel(Logger[localStorage["OpenShiftLogLevel." + a] || "OFF"]), b;
var b = Logger.get("OpenShift/" + a), c = "OFF";
return localStorage && (c = localStorage["OpenShiftLogLevel." + a] || c), b.setLevel(Logger[c]), b;
},
log:function() {
a.log.apply(a, arguments);
Expand All @@ -12731,8 +12731,8 @@ a.warn.apply(a, arguments);
error:function() {
a.error.apply(a, arguments);
}
};
return a.setLevel(Logger[localStorage["OpenShiftLogLevel.main"] || "OFF"]), b;
}, c = "ERROR";
return localStorage && (c = localStorage["OpenShiftLogLevel.main"] || c), a.setLevel(Logger[c]), b;
};
}), angular.module("openshiftConsole").provider("$ws", [ "$httpProvider", function(a) {
this.$get = [ "$q", "$injector", "Logger", function(b, c, d) {
Expand Down Expand Up @@ -12882,7 +12882,9 @@ throw c + " not set";
this.$get = [ "$q", "$injector", "$log", "$rootScope", "Logger", function(e, f, g, h, i) {
var j = i.get("auth");
j.log("AuthServiceProvider.$get", arguments);
var k = $.Callbacks(), l = $.Callbacks(), m = $.Callbacks(), n = null, o = null, p = d(f, a, "AuthServiceProvider.UserStore()"), q = d(f, b, "AuthServiceProvider.LoginService()"), r = d(f, c, "AuthServiceProvider.LogoutService()");
var k = $.Callbacks(), l = $.Callbacks(), m = $.Callbacks(), n = null, o = null, p = d(f, a, "AuthServiceProvider.UserStore()");
p.available() || i.error("AuthServiceProvider.$get user store " + a + " not available");
var q = d(f, b, "AuthServiceProvider.LoginService()"), r = d(f, c, "AuthServiceProvider.LogoutService()");
return {
isLoggedIn:function() {
return !!p.getUser();
Expand Down

0 comments on commit 48fb92a

Please sign in to comment.