https://github.com/angular/angular
Raw File
Tip revision: 7c3b95b4abab2a88ab077d00e2f44a1b0ce5e9bd authored by Victor Berchet on 22 February 2018, 00:42:54 UTC
docs: add changelog for 5.2.6
Tip revision: 7c3b95b
logger.service.ts
import { ErrorHandler, Injectable } from '@angular/core';
import { environment } from '../../environments/environment';


@Injectable()
export class Logger {

  constructor(private errorHandler: ErrorHandler) {}

  log(value: any, ...rest: any[]) {
    if (!environment.production) {
      console.log(value, ...rest);
    }
  }

  error(value: any, ...rest: any[]) {
    const message = [value, ...rest].join(' ');
    this.errorHandler.handleError(message);
  }

  warn(value: any, ...rest: any[]) {
    console.warn(value, ...rest);
  }
}
back to top