Skip to content

Commit

Permalink
logs can be disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
un33k committed Jun 20, 2018
1 parent 922e02c commit f7c6271
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 1.0.4

Bugfix:

- Disable logs on level == none

## 1.0.3

Enhancements:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nwx/logger",
"version": "1.0.3",
"version": "1.0.4",
"repository": {
"type": "git",
"url": "git+https://github.com/neekware/nwx-logger.git"
Expand Down
31 changes: 19 additions & 12 deletions pkgs/logger/src/logger.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,25 @@ export class LogService {
* @param extras extra message
*/
private doLog(level: LogLevels, message: any, extras: any[] = []) {
if (message && level !== LogLevels.none && level <= this._options.log.level) {
if (this.isPlatformIE) {
this.handleIE(level, message, extras);
} else {
const color = LogColors[level];
console.log(
`%c${this.time} [${LogNames[level]}]`,
`color:${color}`,
message,
...extras
);
}
if (
!message ||
level === LogLevels.none ||
level > this._options.log.level ||
this._options.log.level === LogLevels.none
) {
return;
}

if (this.isPlatformIE) {
this.handleIE(level, message, extras);
} else {
const color = LogColors[level];
console.log(
`%c${this.time} [${LogNames[level]}]`,
`color:${color}`,
message,
...extras
);
}
}

Expand Down

0 comments on commit f7c6271

Please sign in to comment.