Skip to content

Commit 8286727

Browse files
committed
Merge pull request #6 from talis/AllowThresholdOverride
90% - Allow override of logging threshold
2 parents 11850e0 + d589b44 commit 8286727

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 2.1.0 (2016-02-23)
2+
3+
Features:
4+
5+
- Allow override of the logging threshold by calling applicationLoggingService.setLoggingThreshold(level)
6+
17
## 2.0.0 (2016-02-19)
28

39
Features:

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "app-logger-angular",
3-
"version": "2.0.0",
3+
"version": "2.1.0",
44
"main": "./js/logging.js",
55
"description": "Client side logging sent to the server",
66
"repository": {

js/logging.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,7 @@ loggingModule.factory(
9191
"applicationLoggingService",
9292
["$log","$window", "LOGGING_CONFIG", function($log, $window, LOGGING_CONFIG){
9393
var arrLoggingLevels = ['trace', 'debug', 'info', 'warn', 'error'];
94-
9594
var loggingThreshold = LOGGING_CONFIG.LOGGING_THRESHOLD || 'info';
96-
9795
var iLoggingThreshold = arrLoggingLevels.indexOf(loggingThreshold);
9896

9997
var isLoggingEnabledForSeverity = function(severity) {
@@ -154,6 +152,16 @@ loggingModule.factory(
154152
},
155153
error: function(message, desc) {
156154
log('error', message, desc);
155+
},
156+
setLoggingThreshold: function(level) {
157+
/*
158+
* Normally the logger would use the logging threshold passed in on the config hash but an
159+
* application may want to override this dynamically, e.g. to enable a different logging
160+
* threshold for a given user.
161+
*/
162+
if (arrLoggingLevels.indexOf(level) !== -1) {
163+
iLoggingThreshold = arrLoggingLevels.indexOf(level);
164+
}
157165
}
158166
});
159167
}]

0 commit comments

Comments
 (0)