* @ngdoc provider * @name $logProvider * @this * * @description * Use the `$logProvider` to configure how the application logs messages
()
| 15523 | * Use the `$logProvider` to configure how the application logs messages |
| 15524 | */ |
| 15525 | function $LogProvider() { |
| 15526 | var debug = true, |
| 15527 | self = this; |
| 15528 | |
| 15529 | /** |
| 15530 | * @ngdoc method |
| 15531 | * @name $logProvider#debugEnabled |
| 15532 | * @description |
| 15533 | * @param {boolean=} flag enable or disable debug level messages |
| 15534 | * @returns {*} current value if used as getter or itself (chaining) if used as setter |
| 15535 | */ |
| 15536 | this.debugEnabled = function(flag) { |
| 15537 | if (isDefined(flag)) { |
| 15538 | debug = flag; |
| 15539 | return this; |
| 15540 | } else { |
| 15541 | return debug; |
| 15542 | } |
| 15543 | }; |
| 15544 | |
| 15545 | this.$get = ['$window', function($window) { |
| 15546 | // Support: IE 9-11, Edge 12-14+ |
| 15547 | // IE/Edge display errors in such a way that it requires the user to click in 4 places |
| 15548 | // to see the stack trace. There is no way to feature-detect it so there's a chance |
| 15549 | // of the user agent sniffing to go wrong but since it's only about logging, this shouldn't |
| 15550 | // break apps. Other browsers display errors in a sensible way and some of them map stack |
| 15551 | // traces along source maps if available so it makes sense to let browsers display it |
| 15552 | // as they want. |
| 15553 | var formatStackTrace = msie || /\bEdge\//.test($window.navigator && $window.navigator.userAgent); |
| 15554 | |
| 15555 | return { |
| 15556 | /** |
| 15557 | * @ngdoc method |
| 15558 | * @name $log#log |
| 15559 | * |
| 15560 | * @description |
| 15561 | * Write a log message |
| 15562 | */ |
| 15563 | log: consoleLog('log'), |
| 15564 | |
| 15565 | /** |
| 15566 | * @ngdoc method |
| 15567 | * @name $log#info |
| 15568 | * |
| 15569 | * @description |
| 15570 | * Write an information message |
| 15571 | */ |
| 15572 | info: consoleLog('info'), |
| 15573 | |
| 15574 | /** |
| 15575 | * @ngdoc method |
| 15576 | * @name $log#warn |
| 15577 | * |
| 15578 | * @description |
| 15579 | * Write a warning message |
| 15580 | */ |
| 15581 | warn: consoleLog('warn'), |
| 15582 |
nothing calls this directly
no test coverage detected