Skip to content

Commit

Permalink
Merge branch 'develop' into ivern_api_factory_callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob McGuinness committed Sep 15, 2015
2 parents e00eae7 + a829183 commit 975a0f8
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"angular-shims-placeholder": "0.4.2",
"angular-ui-router": "0.2.13",
"angular-velocity": "0.3.1",
"availity-uikit": "~0.12.1",
"availity-uikit": "~0.12.3",
"blueimp-file-upload": "9.10.1",
"jquery-ui": "1.11.4",
"jquery.inputmask": "3.1.63",
Expand Down
32 changes: 30 additions & 2 deletions lib/core/logger/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,23 @@
// as the message and the second as array of interpolation variables.
// The output print will be according to this check.
if(typeof args[1] === 'string') {

message = AvLogger.supplant("{0}{1} - {2}(\'{3}\')", [now, context, args[0], args[1]]);

} else {
supplantData = args[1];
message = AvLogger.supplant('{0}{1} - {2}', [now, context, args[0]]);

// If the message is an error, there may be a stack included. If so, we
// should include the stack in the message to make it more meaningful.
if(args[0].stack) {
var errorMessage = this.formatError(args[0]);
message = AvLogger.supplant('{0}{1} - {2}', [now, context, errorMessage]);
supplantData = args[1];

}else {
supplantData = args[1];

}

}
break;
}
Expand Down Expand Up @@ -126,6 +139,21 @@
this._log('debug', arguments);
};

// https://github.com/angular/angular.js/blob/v1.2.27/src/ng/log.js#L122
proto.formatError = function(arg) {
if(arg instanceof Error) {
if(arg.stack) {

arg = (arg.message && arg.stack.indexOf(arg.message) === -1) ?
'Error: ' + arg.message + '\n' + arg.stack : arg.stack;

} else if(arg.sourceURL) {
arg = arg.message + '\n' + arg.sourceURL + ':' + arg.line;
}
}
return arg;
};

proto.error = function() {
this._log('error', arguments);
};
Expand Down

0 comments on commit 975a0f8

Please sign in to comment.