ConsoleLoggingProvider.service.js
2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
(function () {
var app = angular.module('framework.services.logging');
app.service('ConsoleLoggingProvider', ['$window', consoleLoggingProvider]);
function consoleLoggingProvider($window) {
this.log = log;
this.debug = debug;
this.info = info;
this.warning = warning;
this.error = error;
function log(level, catagory, msg, others) {
switch (level) {
case 1:
debug(catagory, msg, others);
break;
case 2:
info(catagory, msg, others);
break;
case 3:
warning(catagory, msg, others);
break;
case 4:
error(catagory, msg, exception, others);
break;
default:
debug(catagory, msg, others);
break;
}
}
function debug(catagory, msg, others) {
var date = new Date();
console.debug(date.toISOString() + ' - ' + catagory.toUpperCase() + ' - ' + msg);
angular.forEach(others, function (val, ind) {
console.debug('additional info ' + ind + ': ', val);
});
}
function info(catagory, msg, others) {
var date = new Date();
console.info(date.toISOString() + ' - ' + catagory.toUpperCase() + ' - ' + msg);
angular.forEach(others, function (val, ind) {
console.info('additional info ' + ind + ': ', val);
});
}
function warning(catagory, msg, others) {
var date = new Date();
console.warn(date.toISOString() + ' - ' + catagory.toUpperCase() + ' - ' + msg);
angular.forEach(others, function (val, ind) {
console.warn('additional info ' + ind + ': ', val);
});
}
function error(catagory, msg, exception, others) {
var date = new Date();
console.error(date.toISOString() + ' - ' + catagory.toUpperCase() + ' - ' + msg);
console.error('original exception: ' + exception);
angular.forEach(others, function (val, ind) {
console.error('additional info ' + ind + ': ', val);
});
}
}
})();