Skip to content

Instantly share code, notes, and snippets.

@wKoza
Last active July 27, 2017 19:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wKoza/4371f77f231e44379f9786b5b33f1d7d to your computer and use it in GitHub Desktop.
Save wKoza/4371f77f231e44379f9786b5b33f1d7d to your computer and use it in GitHub Desktop.
import { Injectable } from '@angular/core';
@Injectable()
export class LoggerService {
logs: Array<string> = [];
level: number= 2; //debug:2, info:1, error:0
debug(message: string) {
this.logs.push(message);
if(this.level == 2) console.log(message);
}
error(message: string){
this.logs.push(message);
if(this.level >= 0)console.error(message);
}
info(message: string){
this.logs.push(message);
if(this.level >= 1) console.info(message);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment