ng2-logger 7.0.13 → 7.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/browser/bundles/ng2-logger.umd.js +36 -34
  2. package/browser/bundles/ng2-logger.umd.js.map +1 -1
  3. package/browser/bundles/ng2-logger.umd.min.js +1 -1
  4. package/browser/bundles/ng2-logger.umd.min.js.map +1 -1
  5. package/browser/esm2015/backend-logging.ngsummary.json +1 -0
  6. package/browser/esm2015/display.ngsummary.json +1 -0
  7. package/browser/esm2015/level.ngsummary.json +1 -0
  8. package/browser/esm2015/log.ngsummary.json +1 -0
  9. package/browser/esm2015/logger.ngsummary.json +1 -0
  10. package/browser/esm2015/ng2-logger.ngsummary.json +1 -0
  11. package/browser/esm2015/public-api.js +2 -1
  12. package/browser/esm2015/public-api.ngsummary.json +1 -0
  13. package/browser/esm5/public-api.js +2 -1
  14. package/browser/fesm2015/ng2-logger.js +1 -1
  15. package/browser/fesm2015/ng2-logger.js.map +1 -1
  16. package/browser/fesm5/ng2-logger.js +1 -1
  17. package/browser/fesm5/ng2-logger.js.map +1 -1
  18. package/browser/ng2-logger.d.ts +0 -1
  19. package/browser/ng2-logger.metadata.json +1 -0
  20. package/browser/package.json +4 -7
  21. package/browser/public-api.d.ts +1 -0
  22. package/client/bundles/ng2-logger.umd.js +36 -34
  23. package/client/bundles/ng2-logger.umd.js.map +1 -1
  24. package/client/bundles/ng2-logger.umd.min.js +1 -1
  25. package/client/bundles/ng2-logger.umd.min.js.map +1 -1
  26. package/client/esm2015/backend-logging.ngsummary.json +1 -0
  27. package/client/esm2015/display.ngsummary.json +1 -0
  28. package/client/esm2015/level.ngsummary.json +1 -0
  29. package/client/esm2015/log.ngsummary.json +1 -0
  30. package/client/esm2015/logger.ngsummary.json +1 -0
  31. package/client/esm2015/ng2-logger.ngsummary.json +1 -0
  32. package/client/esm2015/public-api.js +2 -1
  33. package/client/esm2015/public-api.ngsummary.json +1 -0
  34. package/client/esm5/public-api.js +2 -1
  35. package/client/fesm2015/ng2-logger.js +1 -1
  36. package/client/fesm2015/ng2-logger.js.map +1 -1
  37. package/client/fesm5/ng2-logger.js +1 -1
  38. package/client/fesm5/ng2-logger.js.map +1 -1
  39. package/client/ng2-logger.d.ts +0 -1
  40. package/client/ng2-logger.metadata.json +1 -0
  41. package/client/package.json +4 -7
  42. package/client/public-api.d.ts +1 -0
  43. package/package.json +4 -9
  44. package/package.json_devDependencies.json +1 -1
  45. package/public-api.d.ts +1 -0
  46. package/public-api.js +1 -0
  47. package/public-api.js.map +1 -1
  48. package/tmp-environment.json +6 -6
  49. package/browser/es5/bundles/ng2-logger.umd.js +0 -784
  50. package/browser/es5/bundles/ng2-logger.umd.min.js +0 -186
  51. package/browser/es5/esm2015/backend-logging.js +0 -17
  52. package/browser/es5/esm2015/display.js +0 -89
  53. package/browser/es5/esm2015/level.js +0 -20
  54. package/browser/es5/esm2015/log.js +0 -203
  55. package/browser/es5/esm2015/logger.js +0 -211
  56. package/browser/es5/esm2015/ng2-logger.js +0 -17
  57. package/browser/es5/esm2015/public-api.js +0 -29
  58. package/browser/es5/esm5/backend-logging.js +0 -18
  59. package/browser/es5/esm5/display.js +0 -79
  60. package/browser/es5/esm5/level.js +0 -16
  61. package/browser/es5/esm5/log.js +0 -172
  62. package/browser/es5/esm5/logger.js +0 -190
  63. package/browser/es5/esm5/ng2-logger.js +0 -17
  64. package/browser/es5/esm5/public-api.js +0 -29
  65. package/browser/es5/fesm2015/ng2-logger.js +0 -492
  66. package/browser/es5/fesm5/ng2-logger.js +0 -429
  67. package/client/es5/bundles/ng2-logger.umd.js +0 -784
  68. package/client/es5/bundles/ng2-logger.umd.min.js +0 -186
  69. package/client/es5/esm2015/backend-logging.js +0 -17
  70. package/client/es5/esm2015/display.js +0 -89
  71. package/client/es5/esm2015/level.js +0 -20
  72. package/client/es5/esm2015/log.js +0 -203
  73. package/client/es5/esm2015/logger.js +0 -211
  74. package/client/es5/esm2015/ng2-logger.js +0 -17
  75. package/client/es5/esm2015/public-api.js +0 -29
  76. package/client/es5/esm5/backend-logging.js +0 -18
  77. package/client/es5/esm5/display.js +0 -79
  78. package/client/es5/esm5/level.js +0 -16
  79. package/client/es5/esm5/log.js +0 -172
  80. package/client/es5/esm5/logger.js +0 -190
  81. package/client/es5/esm5/ng2-logger.js +0 -17
  82. package/client/es5/esm5/public-api.js +0 -29
  83. package/client/es5/fesm2015/ng2-logger.js +0 -492
  84. package/client/es5/fesm5/ng2-logger.js +0 -429
@@ -1,186 +0,0 @@
1
- "use strict";
2
-
3
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
4
-
5
- !function (e, t) {
6
- "object" == (typeof exports === "undefined" ? "undefined" : _typeof(exports)) && "undefined" != typeof module ? t(exports, require("tnp-core/browser")) : "function" == typeof define && define.amd ? define("ng2-logger", ["exports", "tnp-core/browser"], t) : t((e = e || self)["ng2-logger"] = {}, e.browser);
7
- }(undefined, function (e, t) {
8
- "use strict";
9
- /*! *****************************************************************************
10
- Copyright (c) Microsoft Corporation.
11
-
12
- Permission to use, copy, modify, and/or distribute this software for any
13
- purpose with or without fee is hereby granted.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
16
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
17
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
18
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
19
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
20
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
21
- PERFORMANCE OF THIS SOFTWARE.
22
- ***************************************************************************** */
23
- Object.create;function o(e, t) {
24
- var o = "function" == typeof Symbol && e[Symbol.iterator];if (!o) return e;var n,
25
- i,
26
- r = o.call(e),
27
- s = [];try {
28
- for (; (void 0 === t || t-- > 0) && !(n = r.next()).done;) {
29
- s.push(n.value);
30
- }
31
- } catch (e) {
32
- i = { error: e };
33
- } finally {
34
- try {
35
- n && !n.done && (o = r.return) && o.call(r);
36
- } finally {
37
- if (i) throw i.error;
38
- }
39
- }return s;
40
- }function n(e, t, o) {
41
- if (o || 2 === arguments.length) for (var n, i = 0, r = t.length; i < r; i++) {
42
- !n && i in t || (n || (n = Array.prototype.slice.call(t, 0, i)), n[i] = t[i]);
43
- }return e.concat(n || t);
44
- }var i, r;Object.create;!function (e) {
45
- e[e.DATA = 0] = "DATA", e[e.INFO = 1] = "INFO", e[e.WARN = 2] = "WARN", e[e.ERROR = 3] = "ERROR", e[e.__NOTHING = 4] = "__NOTHING";
46
- }(r || (r = {}));var s = ((i = {})[r.DATA] = "log", i[r.INFO] = "info", i[r.WARN] = "warn", i[r.ERROR] = "error", i[r.__NOTHING] = "", i),
47
- l = [s[r.DATA], s[r.INFO], s[r.WARN], s[r.ERROR]],
48
- h = function () {
49
- function e() {}return e.msg = function (e, o, n, i, s, l, h) {
50
- if (!h) {
51
- var a = "gray";if (s === r.INFO && (a = "deepskyblue"), s === r.ERROR && (a = "red"), s === r.WARN && (a = "orange"), l) {
52
- var c = l - n.length;if (c > 0) for (var u = 0; u < c; u++) {
53
- n += " ";
54
- }
55
- }if (t.Helpers.isBrowser) if (document.documentMode || /Edge/.test(navigator.userAgent)) {
56
- if ("string" == typeof e) {
57
- var d = "[[ " + n + " ]] " + e + " ";o.unshift(d);
58
- } else {
59
- d = "[[ " + n + "]] ";o.push(e), o.unshift(d);
60
- }s === r.INFO ? console.info.apply(console, o) : s === r.ERROR ? console.error.apply(console, o) : s === r.WARN ? console.warn.apply(console, o) : console.log.apply(console, o);
61
- } else {
62
- if ("string" == typeof e) {
63
- d = "%c " + n + " %c " + e + " ";var f = "background: " + i + ";color:white; border: 1px solid " + i + "; ",
64
- p = "border: 1px solid " + a + "; ";o.unshift(p), o.unshift(f), o.unshift(d);
65
- } else {
66
- d = "%c " + n + " ", f = "background: " + i + ";color:white; border: 1px solid " + a + "; ";o.push(e), o.unshift(f), o.unshift(d);
67
- }console.log.apply(console, o);
68
- }t.Helpers.isNode;
69
- }
70
- }, e;
71
- }(),
72
- a = function () {
73
- function e(e, t, o, n, i, r) {
74
- var s = this;this.name = e, this.color = t, this.developmentMode = o, this.allowed = n, this.isMuted = i, this.fixedWidth = r, this.d = function (e) {
75
- for (var t = [], o = 1; o < arguments.length; o++) {
76
- t[o - 1] = arguments[o];
77
- }return s._data(e, t);
78
- }, this.er = function (e) {
79
- for (var t = [], o = 1; o < arguments.length; o++) {
80
- t[o - 1] = arguments[o];
81
- }return s._error(e, t);
82
- }, this.i = function (e) {
83
- for (var t = [], o = 1; o < arguments.length; o++) {
84
- t[o - 1] = arguments[o];
85
- }return s._info(e, t);
86
- }, this.w = function (e) {
87
- for (var t = [], o = 1; o < arguments.length; o++) {
88
- t[o - 1] = arguments[o];
89
- }return s._warn(e, t);
90
- }, this.data = function (e) {
91
- for (var t = [], o = 1; o < arguments.length; o++) {
92
- t[o - 1] = arguments[o];
93
- }return s._data(e, t);
94
- }, this.error = function (e) {
95
- for (var t = [], o = 1; o < arguments.length; o++) {
96
- t[o - 1] = arguments[o];
97
- }return s._error(e, t);
98
- }, this.info = function (e) {
99
- for (var t = [], o = 1; o < arguments.length; o++) {
100
- t[o - 1] = arguments[o];
101
- }return s._info(e, t);
102
- }, this.warn = function (e) {
103
- for (var t = [], o = 1; o < arguments.length; o++) {
104
- t[o - 1] = arguments[o];
105
- }return s._warn(e, t);
106
- };
107
- }return e.prototype.setLevel = function (e) {
108
- return this._level = e, this;
109
- }, Object.defineProperty(e.prototype, "isProductionMode", { get: function get() {
110
- return !this.developmentMode;
111
- }, enumerable: !1, configurable: !0 }), e.prototype.setProductionMode = function (e) {
112
- return this.developmentMode = !e, this;
113
- }, e.prototype.mute = function () {
114
- return this.isMuted = !0, this;
115
- }, e.prototype.onlyWhen = function (e) {
116
- "function" == typeof e ? this.isMuted = !e() : "boolean" == typeof e && (this.isMuted = !e);
117
- }, e.prototype._data = function (e) {
118
- for (var i = [], s = 1; s < arguments.length; s++) {
119
- i[s - 1] = arguments[s];
120
- }return this.isMuted || this.allowed.length >= 1 && t.Helpers.contain(this.allowed, r.__NOTHING) && !t.Helpers.contain(this.allowed, r.DATA) || (0 === this.allowed.length || t.Helpers.contain(this.allowed, r.DATA)) && h.msg.apply(void 0, n(n([e], o(i)), [this.name, this.color, r.DATA, this.fixedWidth, this.isProductionMode])), this;
121
- }, e.prototype._error = function (e) {
122
- for (var i = [], s = 1; s < arguments.length; s++) {
123
- i[s - 1] = arguments[s];
124
- }return this.isMuted || this.allowed.length >= 1 && t.Helpers.contain(this.allowed, r.__NOTHING) && !t.Helpers.contain(this.allowed, r.ERROR) || (0 === this.allowed.length || t.Helpers.contain(this.allowed, r.ERROR)) && h.msg.apply(void 0, n(n([e], o(i)), [this.name, this.color, r.ERROR, this.fixedWidth, this.isProductionMode])), this;
125
- }, e.prototype._info = function (e) {
126
- for (var i = [], s = 1; s < arguments.length; s++) {
127
- i[s - 1] = arguments[s];
128
- }return this.isMuted || this.allowed.length >= 1 && t.Helpers.contain(this.allowed, r.__NOTHING) && !t.Helpers.contain(this.allowed, r.INFO) || (0 === this.allowed.length || t.Helpers.contain(this.allowed, r.INFO)) && h.msg.apply(void 0, n(n([e], o(i)), [this.name, this.color, r.INFO, this.fixedWidth, this.isProductionMode])), this;
129
- }, e.prototype._warn = function (e) {
130
- for (var i = [], s = 1; s < arguments.length; s++) {
131
- i[s - 1] = arguments[s];
132
- }return this.isMuted || this.allowed.length >= 1 && t.Helpers.contain(this.allowed, r.__NOTHING) && !t.Helpers.contain(this.allowed, r.WARN) || (0 === this.allowed.length || t.Helpers.contain(this.allowed, r.WARN)) && h.msg.apply(void 0, n(n([e], o(i)), [this.name, this.color, r.WARN, this.fixedWidth, this.isProductionMode])), this;
133
- }, e;
134
- }(),
135
- c = function () {
136
- function e() {
137
- this._logOnly = !1, this._logModules = !1, this.isDevelopmentMode = !0, this.modeIsSet = !1, this.fixedWidth = 0, this.instances = {}, this.levels = [], this.modules = [];
138
- }return Object.defineProperty(e, "instance", { get: function get() {
139
- return e._instance || (e._instance = new e()), e._instance;
140
- }, enumerable: !1, configurable: !0 }), e.create = function (t) {
141
- for (var i, r = [], s = 1; s < arguments.length; s++) {
142
- r[s - 1] = arguments[s];
143
- }return (i = e.instance).create.apply(i, n([t], o(r)));
144
- }, e.disableLogs = function (e) {
145
- var t = this;void 0 === e && (e = r.__NOTHING), l.reverse().find(function (o) {
146
- return t.consolelogfn[o] || (t.consolelogfn[o] = console[o]), console[o] = function () {}, o === s[e];
147
- });
148
- }, e.enableLogs = function () {
149
- var e = this;l.forEach(function (t) {
150
- console[t] = e.consolelogfn[t];
151
- });
152
- }, e.prototype.setProductionMode = function () {
153
- var e = this;if (this.modeIsSet) throw this.modeIsSet = !1, "[ng2-logger] Production mode is already set";this.modeIsSet = !0, setTimeout(function () {
154
- e.modeIsSet && void 0 !== console && void 0 !== console.clear && (console.clear(), console.log = function () {}, console.error = function () {}, console.warn = function () {}, console.info = function () {});
155
- }), this.isDevelopmentMode = !1;
156
- }, e.prototype.onlyModules = function () {
157
- for (var e = [], t = 0; t < arguments.length; t++) {
158
- e[t] = arguments[t];
159
- }if (this._logModules) throw "[ng2-logger] You should use funcion onlyModules only once";this._logModules || (this._logModules = !0), 0 !== e.length && (this.modules = e, this.muteAllOtherModules());
160
- }, e.prototype.onlyLevel = function () {
161
- for (var e = [], t = 0; t < arguments.length; t++) {
162
- e[t] = arguments[t];
163
- }if (this._logOnly) throw "[ng2-logger] You should use funcion onlyLevel only once";for (var o in this._logOnly || (this._logOnly = !0), this.levels = Array.isArray(e) ? e : [e], this.instances) {
164
- if (this.instances.hasOwnProperty(o)) {
165
- var n = this.instances[o];n.allowed = this.levels;
166
- }
167
- }
168
- }, e.prototype.create = function (t) {
169
- for (var o, n = [], i = 1; i < arguments.length; i++) {
170
- n[i - 1] = arguments[i];
171
- }return Array.isArray(this.levels) && this.levels.length > 0 && (n = this.levels), void 0 === this.instances[t] ? (o = new e.Logger(t, u(), this.isDevelopmentMode, n, this.isMutedModule(t), this.levels.length > 0 ? this.fixedWidth : void 0), this.instances[t] = o) : o = this.instances[t], o;
172
- }, e.prototype.isMutedModule = function (e) {
173
- return 0 != this.modules.length && !t.Helpers.contain(this.modules, e);
174
- }, e.prototype.muteAllOtherModules = function () {
175
- for (var e in this.instances) {
176
- t.Helpers.contain(this.modules, e) || this.instances[e].mute();
177
- }
178
- }, e.Logger = a, e.consolelogfn = {}, e;
179
- }();function u() {
180
- var e = "012345".split(""),
181
- t = "#";t += e[Math.round(5 * Math.random())], e = "0123456789ABCDEF".split("");for (var o = 0; o < 5; o++) {
182
- t += e[Math.round(15 * Math.random())];
183
- }return void 0 === t ? u() : t;
184
- }e.Log = c, e.Logger = a, Object.defineProperty(e, "__esModule", { value: !0 });
185
- });
186
- //# sourceMappingURL=ng2-logger.umd.min.js.map
@@ -1,17 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.consoleLog = consoleLog;
7
- exports.displayParams = displayParams;
8
- exports.istartedInVscode = istartedInVscode;
9
- function consoleLog(data, level) {}
10
- function displayParams() {
11
- var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
12
- var level = arguments[1];
13
- }
14
- function replace(out, match, char, color) {}
15
- function handleObjectData(param, level) {}
16
- function istartedInVscode() {}
17
- function isObjectAfterStringify(s) {}
@@ -1,89 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.Display = undefined;
7
-
8
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
9
-
10
- var _level = require('./level');
11
-
12
- var _browser = require('tnp-core/browser');
13
-
14
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
15
-
16
- var Display = exports.Display = function () {
17
- function Display() {
18
- _classCallCheck(this, Display);
19
- }
20
-
21
- _createClass(Display, null, [{
22
- key: 'msg',
23
- value: function msg(message, params, moduleName, moduleColor, level, moduleWidth, isProductionMode) {
24
- if (isProductionMode) {
25
- return;
26
- }
27
- ;
28
- var color = 'gray';
29
- if (level === _level.Level.INFO) {
30
- color = 'deepskyblue';
31
- }
32
- if (level === _level.Level.ERROR) {
33
- color = 'red';
34
- }
35
- if (level === _level.Level.WARN) {
36
- color = 'orange';
37
- }
38
- if (moduleWidth) {
39
- var diff = moduleWidth - moduleName.length;
40
- if (diff > 0) {
41
- for (var i = 0; i < diff; i++) {
42
- moduleName += ' ';
43
- }
44
- }
45
- }
46
- if (_browser.Helpers.isBrowser) {
47
- var isEdgeOrIe8orAbove = document['documentMode'] || /Edge/.test(navigator.userAgent);
48
- if (isEdgeOrIe8orAbove) {
49
- if (typeof message === 'string') {
50
- var a1 = '[[ ' + moduleName + ' ]] ' + message + ' ';
51
- params.unshift(a1);
52
- } else {
53
- var _a = '[[ ' + moduleName + ']] ';
54
- params.push(message);
55
- params.unshift(_a);
56
- }
57
- if (level === _level.Level.INFO) {
58
- console.info.apply(console, params);
59
- } else if (level === _level.Level.ERROR) {
60
- console.error.apply(console, params);
61
- } else if (level === _level.Level.WARN) {
62
- console.warn.apply(console, params);
63
- } else {
64
- console.log.apply(console, params);
65
- }
66
- } else {
67
- if (typeof message === 'string') {
68
- var _a2 = '%c ' + moduleName + ' %c ' + message + ' ';
69
- var a2 = 'background: ' + moduleColor + ';color:white; border: 1px solid ' + moduleColor + '; ';
70
- var a3 = 'border: 1px solid ' + color + '; ';
71
- params.unshift(a3);
72
- params.unshift(a2);
73
- params.unshift(_a2);
74
- } else {
75
- var _a3 = '%c ' + moduleName + ' ';
76
- var _a4 = 'background: ' + moduleColor + ';color:white; border: 1px solid ' + color + '; ';
77
- params.push(message);
78
- params.unshift(_a4);
79
- params.unshift(_a3);
80
- }
81
- console.log.apply(console, params);
82
- }
83
- }
84
- if (_browser.Helpers.isNode) {}
85
- }
86
- }]);
87
-
88
- return Display;
89
- }();
@@ -1,20 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- var _LevelKey;
8
-
9
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
10
-
11
- var Level = exports.Level = undefined;
12
- (function (Level) {
13
- Level[Level["DATA"] = 0] = "DATA";
14
- Level[Level["INFO"] = 1] = "INFO";
15
- Level[Level["WARN"] = 2] = "WARN";
16
- Level[Level["ERROR"] = 3] = "ERROR";
17
- Level[Level["__NOTHING"] = 4] = "__NOTHING";
18
- })(Level || (exports.Level = Level = {}));
19
- var LevelKey = exports.LevelKey = (_LevelKey = {}, _defineProperty(_LevelKey, Level.DATA, 'log'), _defineProperty(_LevelKey, Level.INFO, 'info'), _defineProperty(_LevelKey, Level.WARN, 'warn'), _defineProperty(_LevelKey, Level.ERROR, 'error'), _defineProperty(_LevelKey, Level.__NOTHING, ''), _LevelKey);
20
- var LevelOrder = exports.LevelOrder = [LevelKey[Level.DATA], LevelKey[Level.INFO], LevelKey[Level.WARN], LevelKey[Level.ERROR]];
@@ -1,203 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.Log = undefined;
7
-
8
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
9
-
10
- var _logger = require('./logger');
11
-
12
- var _level = require('./level');
13
-
14
- var _browser = require('tnp-core/browser');
15
-
16
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
17
-
18
- var Log = exports.Log = function () {
19
- //#region singleton
20
- function Log() {
21
- _classCallCheck(this, Log);
22
-
23
- this._logOnly = false;
24
- this._logModules = false;
25
- this.isDevelopmentMode = true;
26
- this.modeIsSet = false;
27
- this.fixedWidth = 0;
28
- this.instances = {};
29
- this.levels = [];
30
- this.modules = [];
31
- }
32
- // @ts-ignore
33
-
34
-
35
- _createClass(Log, [{
36
- key: 'setProductionMode',
37
-
38
- //#region public api
39
- value: function setProductionMode() {
40
- var _this = this;
41
-
42
- if (this.modeIsSet) {
43
- this.modeIsSet = false;
44
- throw '[ng2-logger] Production mode is already set';
45
- } else {
46
- this.modeIsSet = true;
47
- setTimeout(function () {
48
- if (_this.modeIsSet && console !== void 0 && console.clear !== void 0) {
49
- console.clear();
50
- console.log = function () {};
51
- console.error = function () {};
52
- console.warn = function () {};
53
- console.info = function () {};
54
- }
55
- });
56
- this.isDevelopmentMode = false;
57
- }
58
- }
59
- }, {
60
- key: 'onlyModules',
61
- value: function onlyModules() {
62
- if (this._logModules) {
63
- throw '[ng2-logger] You should use funcion onlyModules only once';
64
- }
65
- if (!this._logModules) {
66
- this._logModules = true;
67
- }
68
-
69
- for (var _len = arguments.length, modules = Array(_len), _key = 0; _key < _len; _key++) {
70
- modules[_key] = arguments[_key];
71
- }
72
-
73
- if (modules.length === 0) return;
74
- this.modules = modules;
75
- // console.log('only log this', Log.modules)
76
- this.muteAllOtherModules();
77
- }
78
- }, {
79
- key: 'onlyLevel',
80
- value: function onlyLevel() {
81
- if (this._logOnly) {
82
- throw '[ng2-logger] You should use funcion onlyLevel only once';
83
- }
84
- if (!this._logOnly) {
85
- this._logOnly = true;
86
- }
87
-
88
- for (var _len2 = arguments.length, level = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
89
- level[_key2] = arguments[_key2];
90
- }
91
-
92
- this.levels = Array.isArray(level) ? level : [level];
93
- for (var logName in this.instances) {
94
- if (this.instances.hasOwnProperty(logName)) {
95
- var element = this.instances[logName];
96
- element['allowed'] = this.levels;
97
- }
98
- }
99
- }
100
- //#endregion
101
-
102
- }, {
103
- key: 'create',
104
- value: function create(name) {
105
- for (var _len3 = arguments.length, level = Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
106
- level[_key3 - 1] = arguments[_key3];
107
- }
108
-
109
- var i = void 0;
110
- if (Array.isArray(this.levels) && this.levels.length > 0) {
111
- level = this.levels;
112
- }
113
- if (this.instances[name] === void 0) {
114
- i = new Log.Logger(name, getRandomColor(), this.isDevelopmentMode, level, this.isMutedModule(name), this.levels.length > 0 ? this.fixedWidth : void 0);
115
- this.instances[name] = i;
116
- } else {
117
- i = this.instances[name];
118
- }
119
- return i;
120
- }
121
- }, {
122
- key: 'isMutedModule',
123
- value: function isMutedModule(moduleName) {
124
- if (this.modules.length == 0) return false;
125
- if (!_browser.Helpers.contain(this.modules, moduleName)) return true;
126
- return false;
127
- }
128
- }, {
129
- key: 'muteAllOtherModules',
130
- value: function muteAllOtherModules() {
131
- for (var moduleName in this.instances) {
132
- if (!_browser.Helpers.contain(this.modules, moduleName)) this.instances[moduleName].mute();
133
- }
134
- }
135
- }], [{
136
- key: 'create',
137
- value: function create(name) {
138
- var _Log$instance;
139
-
140
- for (var _len4 = arguments.length, level = Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
141
- level[_key4 - 1] = arguments[_key4];
142
- }
143
-
144
- return (_Log$instance = Log.instance).create.apply(_Log$instance, [name].concat(level));
145
- }
146
- }, {
147
- key: 'disableLogs',
148
- value: function disableLogs() {
149
- var _this2 = this;
150
-
151
- var level = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _level.Level.__NOTHING;
152
-
153
- _level.LevelOrder.reverse().find(function (a) {
154
- if (!_this2.consolelogfn[a]) {
155
- _this2.consolelogfn[a] = console[a];
156
- }
157
- console[a] = function () {};
158
- if (a === _level.LevelKey[level]) {
159
- return true;
160
- }
161
- return false;
162
- });
163
- }
164
- }, {
165
- key: 'enableLogs',
166
- value: function enableLogs() {
167
- var _this3 = this;
168
-
169
- _level.LevelOrder.forEach(function (a) {
170
- console[a] = _this3.consolelogfn[a];
171
- });
172
- }
173
- }, {
174
- key: 'instance',
175
- get: function get() {
176
- if (!Log['_instance']) {
177
- Log['_instance'] = new Log();
178
- }
179
- return Log['_instance'];
180
- }
181
- }]);
182
-
183
- return Log;
184
- }();
185
- //#endregion
186
-
187
-
188
- Log.Logger = _logger.Logger;
189
- Log.consolelogfn = {};
190
- function getRandomColor() {
191
- var letters = '012345'.split('');
192
- var color = '#';
193
- color += letters[Math.round(Math.random() * 5)];
194
- letters = '0123456789ABCDEF'.split('');
195
- for (var i = 0; i < 5; i++) {
196
- color += letters[Math.round(Math.random() * 15)];
197
- }
198
- if (color === void 0) {
199
- return getRandomColor();
200
- }
201
- ;
202
- return color;
203
- }