Skip to content

Commit 7962912

Browse files
committed
feat(log): support optional log level param to developmentLogging().
So we can do aurelia.use.developmentLogging(environment.debug ? 'debug' : 'warn'); to still see error/warn in production app.
1 parent 410e235 commit 7962912

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/framework-configuration.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,14 +350,20 @@ export class FrameworkConfiguration {
350350

351351
/**
352352
* Plugs in the ConsoleAppender and sets the log level to debug.
353+
* @param level The log level (none/error/warn/info/debug), default to 'debug'.
353354
* @return {FrameworkConfiguration} Returns the current FrameworkConfiguration instance.
354355
*/
355-
developmentLogging(): FrameworkConfiguration {
356+
developmentLogging(level?: String): FrameworkConfiguration {
357+
let logLevel = level ? TheLogManager.logLevel[level] : undefined
358+
if (logLevel === undefined) {
359+
logLevel = TheLogManager.logLevel.debug;
360+
}
361+
356362
this.preTask(() => {
357363
return this.aurelia.loader.normalize('aurelia-logging-console', this.bootstrapperName).then(name => {
358364
return this.aurelia.loader.loadModule(name).then(m => {
359365
TheLogManager.addAppender(new m.ConsoleAppender());
360-
TheLogManager.setLevel(TheLogManager.logLevel.debug);
366+
TheLogManager.setLevel(logLevel);
361367
});
362368
});
363369
});

0 commit comments

Comments
 (0)