* @ngdoc provider * @name $logProvider * @this * * @description * Use the `$logProvider` to configure how the application logs messages
()
| 14682 | * Use the `$logProvider` to configure how the application logs messages |
| 14683 | */ |
| 14684 | function $LogProvider() { |
| 14685 | var debug = true, |
| 14686 | self = this; |
| 14687 | |
| 14688 | /** |
| 14689 | * @ngdoc method |
| 14690 | * @name $logProvider#debugEnabled |
| 14691 | * @description |
| 14692 | * @param {boolean=} flag enable or disable debug level messages |
| 14693 | * @returns {*} current value if used as getter or itself (chaining) if used as setter |
| 14694 | */ |
| 14695 | this.debugEnabled = function(flag) { |
| 14696 | if (isDefined(flag)) { |
| 14697 | debug = flag; |
| 14698 | return this; |
| 14699 | } else { |
| 14700 | return debug; |
| 14701 | } |
| 14702 | }; |
| 14703 | |
| 14704 | this.$get = ['$window', function($window) { |
| 14705 | // Support: IE 9-11, Edge 12-14+ |
| 14706 | // IE/Edge display errors in such a way that it requires the user to click in 4 places |
| 14707 | // to see the stack trace. There is no way to feature-detect it so there's a chance |
| 14708 | // of the user agent sniffing to go wrong but since it's only about logging, this shouldn't |
| 14709 | // break apps. Other browsers display errors in a sensible way and some of them map stack |
| 14710 | // traces along source maps if available so it makes sense to let browsers display it |
| 14711 | // as they want. |
| 14712 | var formatStackTrace = msie || /\bEdge\//.test($window.navigator && $window.navigator.userAgent); |
| 14713 | |
| 14714 | return { |
| 14715 | /** |
| 14716 | * @ngdoc method |
| 14717 | * @name $log#log |
| 14718 | * |
| 14719 | * @description |
| 14720 | * Write a log message |
| 14721 | */ |
| 14722 | log: consoleLog('log'), |
| 14723 | |
| 14724 | /** |
| 14725 | * @ngdoc method |
| 14726 | * @name $log#info |
| 14727 | * |
| 14728 | * @description |
| 14729 | * Write an information message |
| 14730 | */ |
| 14731 | info: consoleLog('info'), |
| 14732 | |
| 14733 | /** |
| 14734 | * @ngdoc method |
| 14735 | * @name $log#warn |
| 14736 | * |
| 14737 | * @description |
| 14738 | * Write a warning message |
| 14739 | */ |
| 14740 | warn: consoleLog('warn'), |
| 14741 |
nothing calls this directly
no test coverage detected