* @ngdoc provider * @name $logProvider * @this * * @description * Use the `$logProvider` to configure how the application logs messages
()
| 14884 | * Use the `$logProvider` to configure how the application logs messages |
| 14885 | */ |
| 14886 | function $LogProvider() { |
| 14887 | var debug = true, |
| 14888 | self = this; |
| 14889 | |
| 14890 | /** |
| 14891 | * @ngdoc method |
| 14892 | * @name $logProvider#debugEnabled |
| 14893 | * @description |
| 14894 | * @param {boolean=} flag enable or disable debug level messages |
| 14895 | * @returns {*} current value if used as getter or itself (chaining) if used as setter |
| 14896 | */ |
| 14897 | this.debugEnabled = function(flag) { |
| 14898 | if (isDefined(flag)) { |
| 14899 | debug = flag; |
| 14900 | return this; |
| 14901 | } else { |
| 14902 | return debug; |
| 14903 | } |
| 14904 | }; |
| 14905 | |
| 14906 | this.$get = ['$window', function($window) { |
| 14907 | // Support: IE 9-11, Edge 12-14+ |
| 14908 | // IE/Edge display errors in such a way that it requires the user to click in 4 places |
| 14909 | // to see the stack trace. There is no way to feature-detect it so there's a chance |
| 14910 | // of the user agent sniffing to go wrong but since it's only about logging, this shouldn't |
| 14911 | // break apps. Other browsers display errors in a sensible way and some of them map stack |
| 14912 | // traces along source maps if available so it makes sense to let browsers display it |
| 14913 | // as they want. |
| 14914 | var formatStackTrace = msie || /\bEdge\//.test($window.navigator && $window.navigator.userAgent); |
| 14915 | |
| 14916 | return { |
| 14917 | /** |
| 14918 | * @ngdoc method |
| 14919 | * @name $log#log |
| 14920 | * |
| 14921 | * @description |
| 14922 | * Write a log message |
| 14923 | */ |
| 14924 | log: consoleLog('log'), |
| 14925 | |
| 14926 | /** |
| 14927 | * @ngdoc method |
| 14928 | * @name $log#info |
| 14929 | * |
| 14930 | * @description |
| 14931 | * Write an information message |
| 14932 | */ |
| 14933 | info: consoleLog('info'), |
| 14934 | |
| 14935 | /** |
| 14936 | * @ngdoc method |
| 14937 | * @name $log#warn |
| 14938 | * |
| 14939 | * @description |
| 14940 | * Write a warning message |
| 14941 | */ |
| 14942 | warn: consoleLog('warn'), |
| 14943 |
nothing calls this directly
no test coverage detected