Skip to content

Commit

Permalink
feat(log): support optional log level param to developmentLogging().
Browse files Browse the repository at this point in the history
So we can do aurelia.use.developmentLogging(environment.debug ? 'debug' : 'warn'); to still see error/warn in production app.
  • Loading branch information
3cp committed Jan 12, 2018
1 parent 410e235 commit 7962912
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/framework-configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,14 +350,20 @@ export class FrameworkConfiguration {

/**
* Plugs in the ConsoleAppender and sets the log level to debug.
* @param level The log level (none/error/warn/info/debug), default to 'debug'.
* @return {FrameworkConfiguration} Returns the current FrameworkConfiguration instance.
*/
developmentLogging(): FrameworkConfiguration {
developmentLogging(level?: String): FrameworkConfiguration {
let logLevel = level ? TheLogManager.logLevel[level] : undefined
if (logLevel === undefined) {
logLevel = TheLogManager.logLevel.debug;
}

this.preTask(() => {
return this.aurelia.loader.normalize('aurelia-logging-console', this.bootstrapperName).then(name => {
return this.aurelia.loader.loadModule(name).then(m => {
TheLogManager.addAppender(new m.ConsoleAppender());
TheLogManager.setLevel(TheLogManager.logLevel.debug);
TheLogManager.setLevel(logLevel);
});
});
});
Expand Down

0 comments on commit 7962912

Please sign in to comment.