From b9c3867447df23f69b5420d827e24ef3322e90bf Mon Sep 17 00:00:00 2001 From: Steve Ellis Date: Thu, 12 Mar 2020 16:15:47 +0000 Subject: [PATCH 1/2] Adding in a callback function that allows for errors to be optionally filtered out before being sent on --- bower.json | 2 +- js/logging.js | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/bower.json b/bower.json index 4ececbd..e967d76 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "app-logger-angular", - "version": "2.1.8", + "version": "2.2.0", "main": "./js/logging.js", "description": "Client side logging sent to the server", "repository": { diff --git a/js/logging.js b/js/logging.js index 289c0ce..ea23509 100644 --- a/js/logging.js +++ b/js/logging.js @@ -49,6 +49,10 @@ loggingModule.factory( $log.error.apply($log, arguments); } + if($window.talisLogger.onBeforeLogError && !$window.talisLogger.onBeforeLogError(exception)) { + return false; + } + if (LOGGING_CONFIG.FORWARD_TO_NEWRELIC && $window.NREUM && $window.NREUM.noticeError) { $window.NREUM.noticeError(exception); } @@ -95,6 +99,7 @@ loggingModule.factory( var arrLoggingLevels = ['trace', 'debug', 'info', 'warn', 'error']; var loggingThreshold = LOGGING_CONFIG.LOGGING_THRESHOLD || 'info'; var iLoggingThreshold = arrLoggingLevels.indexOf(loggingThreshold); + $window.talisLogger = {}; /* * If we've told applicationLoggingService to override the logging threshold set in config then also pass @@ -123,6 +128,7 @@ loggingModule.factory( return; } + if (LOGGING_CONFIG.LOGGING_TYPE !== 'none') { // preserve default behaviour var angularLogSeverity = severity; @@ -139,6 +145,10 @@ loggingModule.factory( } } + if($window.talisLogger.onBeforeLogError && !$window.talisLogger.onBeforeLogError(message)) { + return false; + } + if (sendToNewRelic && $window.NREUM && $window.NREUM.noticeError) { $window.NREUM.noticeError(message, {desc: desc}); } From 6f7f5001eb59a20e173bcc8779acabba0b3be877 Mon Sep 17 00:00:00 2001 From: Steve Ellis Date: Thu, 12 Mar 2020 16:18:32 +0000 Subject: [PATCH 2/2] Deleting a bonus newline --- js/logging.js | 1 - 1 file changed, 1 deletion(-) diff --git a/js/logging.js b/js/logging.js index ea23509..c483fe7 100644 --- a/js/logging.js +++ b/js/logging.js @@ -128,7 +128,6 @@ loggingModule.factory( return; } - if (LOGGING_CONFIG.LOGGING_TYPE !== 'none') { // preserve default behaviour var angularLogSeverity = severity;