Last active
May 13, 2016 07:20
-
-
Save nicolanrizzo/d12293fe0ab95cb4d98edb90a1ff3559 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.config(["$provide", "$windowProvider", function ($provide, $windowProvider) { | |
var $window = $windowProvider.$get(); | |
$provide.decorator('$log', function ($delegate){ | |
function appLogging(message, type) { | |
$.ajax({ | |
type: "POST", | |
url: "http://10.10.10.10:8080", | |
contentType: "application/json", | |
data: angular.toJson({ | |
url: $window.location.href, | |
content: message, | |
type: type, | |
userAgent: $window.navigator.userAgent, | |
userLang: $window.navigator.language | |
}) | |
}); | |
} | |
return { | |
log: function(message) { | |
appLogging(message, "log"); | |
return $delegate.log(message); | |
}, | |
info: function(message) { | |
appLogging(message, "info"); | |
return $delegate.info(message); | |
}, | |
warn: function(message) { | |
appLogging(message, "warn"); | |
return $delegate.warn(message); | |
}, | |
error: function(message) { | |
if (message.stack) { | |
message = (message.message && message.stack.indexOf(message.message) === -1) | |
? 'Error: ' + message.message + '\n' + message.stack | |
: message.stack; | |
} else if (message.sourceURL) { | |
message = message.message + '\n' + message.sourceURL + ':' + message.line; | |
} | |
appLogging(message, "angularError"); | |
return $delegate.error(message); | |
}, | |
debug: function(message) { | |
appLogging(message, "debug"); | |
return $delegate.debug(message); | |
} | |
}; | |
}); | |
}]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment