feat(exception_handler): changed ExceptionHandler to use console.error instead of console.log

Closes #3812
This commit is contained in:
vsavkin 2015-08-24 11:35:27 -07:00 committed by Victor Savkin
parent a34d4c6a5f
commit 3bb27deecc
7 changed files with 22 additions and 10 deletions

View File

@ -157,6 +157,7 @@ class BrowserDomAdapter extends GenericBrowserDomAdapter {
logGroup(error) {
window.console.group(error);
this.logError(error);
}
logGroupEnd() {

View File

@ -64,13 +64,20 @@ export class BrowserDomAdapter extends GenericBrowserDomAdapter {
}
// TODO(tbosch): move this into a separate environment class once we have it
logError(error) { window.console.error(error); }
logError(error) {
if (window.console.error) {
window.console.error(error);
} else {
window.console.log(error);
}
}
log(error) { window.console.log(error); }
logGroup(error) {
if (window.console.group) {
window.console.group(error);
this.logError(error);
} else {
window.console.log(error);
}

View File

@ -52,7 +52,7 @@ export class Parse5DomAdapter extends DomAdapter {
log(error) { console.log(error); }
logGroup(error) { console.log(error); }
logGroup(error) { console.error(error); }
logGroupEnd() {}

View File

@ -5,6 +5,7 @@ import {ListWrapper, isListLikeIterable} from 'angular2/src/core/facade/collecti
class _ArrayLogger {
res: any[] = [];
log(s: any): void { this.res.push(s); }
logError(s: any): void { this.res.push(s); }
logGroup(s: any): void { this.res.push(s); }
logGroupEnd(){};
}
@ -49,26 +50,26 @@ export class ExceptionHandler {
this.logger.logGroup(`EXCEPTION: ${exception}`);
if (isPresent(stackTrace) && isBlank(originalStack)) {
this.logger.log("STACKTRACE:");
this.logger.log(this._longStackTrace(stackTrace));
this.logger.logError("STACKTRACE:");
this.logger.logError(this._longStackTrace(stackTrace));
}
if (isPresent(reason)) {
this.logger.log(`REASON: ${reason}`);
this.logger.logError(`REASON: ${reason}`);
}
if (isPresent(originalException)) {
this.logger.log(`ORIGINAL EXCEPTION: ${originalException}`);
this.logger.logError(`ORIGINAL EXCEPTION: ${originalException}`);
}
if (isPresent(originalStack)) {
this.logger.log("ORIGINAL STACKTRACE:");
this.logger.log(this._longStackTrace(originalStack));
this.logger.logError("ORIGINAL STACKTRACE:");
this.logger.logError(this._longStackTrace(originalStack));
}
if (isPresent(context)) {
this.logger.log("ERROR CONTEXT:");
this.logger.log(context);
this.logger.logError("ERROR CONTEXT:");
this.logger.logError(context);
}
this.logger.logGroupEnd();

View File

@ -71,6 +71,7 @@ var _rootBindings = [bind(Reflector).toValue(reflector)];
class PrintLogger {
log = print;
logError = print;
logGroup = print;
logGroupEnd() {}
}

View File

@ -69,6 +69,7 @@ class HelloRootDirectiveIsNotCmp {
class _ArrayLogger {
res: any[] = [];
log(s: any): void { this.res.push(s); }
logError(s: any): void { this.res.push(s); }
logGroup(s: any): void { this.res.push(s); }
logGroupEnd(){};
}

View File

@ -33,6 +33,7 @@ import {MockLocationStrategy} from 'angular2/src/mock/mock_location_strategy';
class _ArrayLogger {
res: any[] = [];
log(s: any): void { this.res.push(s); }
logError(s: any): void { this.res.push(s); }
logGroup(s: any): void { this.res.push(s); }
logGroupEnd(){};
}