angular/aio/src/app/shared/logger.service.ts
Pete Bacon Darwin 049757b237 fix(aio): constrain error logging to improve reporting (#22713)
The `Logger.error()` method now only accepts a single `Error` parameter
and passes this through to the error handler.
This allows the error handler to serialize the error more accurately.

The various places that use `Logger.error()` have been updated.

See #21943#issuecomment-370230047

PR Close #22713
2018-03-14 10:52:11 -07:00

24 lines
478 B
TypeScript

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(error: Error) {
this.errorHandler.handleError(error);
}
warn(value: any, ...rest: any[]) {
console.warn(value, ...rest);
}
}