[Logging] Wire in log levels

Wire in log levels to allow specifying as a query string
parameter; defaults to logging only warnings and above,
for WTD-793.
This commit is contained in:
Victor Woeltjen 2015-02-03 18:42:30 -08:00
parent 6dd8a4ccca
commit c0163d2d60
2 changed files with 17 additions and 2 deletions

View File

@ -43,7 +43,6 @@ define(
log[m] = NOOP;
}
});
return log;
}
// Default to 'warn' level if unspecified
@ -67,7 +66,10 @@ define(
configure: function (app, $log) {
decorate($log);
app.config(function ($provide) {
$provide.decorator('$log', decorate);
$provide.decorator('$log', function ($delegate) {
decorate($delegate);
return $delegate;
});
});
}
};

View File

@ -19,6 +19,7 @@ define(
'../lib/angular-route.min',
'./Constants',
'./FrameworkInitializer',
'./LogLevel',
'./load/BundleLoader',
'./resolve/ImplementationLoader',
'./resolve/ExtensionResolver',
@ -36,6 +37,7 @@ define(
angularRoute,
Constants,
FrameworkInitializer,
LogLevel,
BundleLoader,
ImplementationLoader,
ExtensionResolver,
@ -52,6 +54,12 @@ define(
// services, which are useful to the framework layer.
var injector = angular.injector(['ng']);
// Look up log level from query string
function logLevel() {
var match = /[?&]log=([a-z]+)/.exec(window.location.search);
return match ? match[1] : "";
}
// Polyfill Promise, in case browser does not natively provide Promise
window.Promise = window.Promise || es6promise.Promise;
@ -86,6 +94,11 @@ define(
bootstrapper
);
// Apply logging levels; this must be done now, before the
// first log statement.
new LogLevel(logLevel()).configure(app, $log);
// Initialize the application
$log.info("Initializing application.");
initializer.runApplication(Constants.BUNDLE_LISTING_FILE);
}