Skip to content

Commit

Permalink
Fixed log level filtering for Logger (#379).
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo committed Mar 17, 2020
1 parent 9ea16e5 commit 72c8992
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/logger/src.ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
let _permanentCensorErrors = false;
let _censorErrors = false;

const LogLevels: { [ name: string ]: number } = { debug: 1, "default": 2, info: 2, warn: 3, error: 4, off: 5 };
const LogLevels: { [ name: string ]: number } = { debug: 1, "default": 2, info: 2, warning: 3, error: 4, off: 5 };
let LogLevel = LogLevels["default"];

import { version } from "./_version";
Expand Down Expand Up @@ -152,7 +152,11 @@ export class Logger {
}

_log(logLevel: LogLevel, args: Array<any>): void {
if (LogLevel > LogLevels[logLevel]) { return; }
const level = logLevel.toLowerCase();
if (LogLevels[level] == null) {
this.throwArgumentError("invalid log level name", "logLevel", logLevel);
}
if (LogLevel > LogLevels[level]) { return; }
console.log.apply(console, args);
}

Expand Down

0 comments on commit 72c8992

Please sign in to comment.