infront-logger 1.1.14 → 1.1.16
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.
- package/dist/browser.es.js +23 -3
- package/dist/browser.umd.js +23 -3
- package/dist/index.es.js +33 -4
- package/dist/index.umd.js +33 -4
- package/package.json +1 -1
package/dist/browser.es.js
CHANGED
|
@@ -4127,6 +4127,14 @@ const DEFAULTS = {
|
|
|
4127
4127
|
forwardErrorsToLogs: false,
|
|
4128
4128
|
sessionSampleRate: 100
|
|
4129
4129
|
};
|
|
4130
|
+
const connection = () => {
|
|
4131
|
+
var _a2, _b, _c, _d, _e, _f;
|
|
4132
|
+
return {
|
|
4133
|
+
downlink: (_b = (_a2 = window == null ? void 0 : window.navigator) == null ? void 0 : _a2.connection) == null ? void 0 : _b.downlink,
|
|
4134
|
+
effectiveType: (_d = (_c = window == null ? void 0 : window.navigator) == null ? void 0 : _c.connection) == null ? void 0 : _d.effectiveType,
|
|
4135
|
+
rtt: (_f = (_e = window == null ? void 0 : window.navigator) == null ? void 0 : _e.connection) == null ? void 0 : _f.rtt
|
|
4136
|
+
};
|
|
4137
|
+
};
|
|
4130
4138
|
class DatadogLogger {
|
|
4131
4139
|
constructor(options = {}) {
|
|
4132
4140
|
if (!options.clientToken) {
|
|
@@ -4148,18 +4156,20 @@ class DatadogLogger {
|
|
|
4148
4156
|
this.options = options;
|
|
4149
4157
|
this.logger = datadogLogs.logger;
|
|
4150
4158
|
this.ctx = {};
|
|
4159
|
+
this.startTime = Date.now();
|
|
4160
|
+
this.absaluteStartTime = Date.now();
|
|
4151
4161
|
}
|
|
4152
4162
|
log() {
|
|
4153
4163
|
let normalized = normalizeArgs(...arguments);
|
|
4154
|
-
this.logger.log(normalized.message, Object.assign(normalized.properties, this.ctx));
|
|
4164
|
+
this.logger.log(normalized.message, Object.assign(normalized.properties, { connection: connection() }, this.ctx));
|
|
4155
4165
|
}
|
|
4156
4166
|
info() {
|
|
4157
4167
|
let normalized = normalizeArgs(...arguments);
|
|
4158
|
-
this.logger.info(normalized.message, Object.assign(normalized.properties, this.ctx));
|
|
4168
|
+
this.logger.info(normalized.message, Object.assign(normalized.properties, { connection: connection() }, this.ctx));
|
|
4159
4169
|
}
|
|
4160
4170
|
error() {
|
|
4161
4171
|
let normalized = normalizeArgs(...arguments);
|
|
4162
|
-
this.logger.error(normalized.message, Object.assign(normalized.properties, this.ctx), normalized.error);
|
|
4172
|
+
this.logger.error(normalized.message, Object.assign(normalized.properties, { connection: connection() }, this.ctx), normalized.error);
|
|
4163
4173
|
}
|
|
4164
4174
|
context(key, value) {
|
|
4165
4175
|
if (typeof key === "string") {
|
|
@@ -4169,6 +4179,16 @@ class DatadogLogger {
|
|
|
4169
4179
|
}
|
|
4170
4180
|
return this;
|
|
4171
4181
|
}
|
|
4182
|
+
profile(action, options = {}) {
|
|
4183
|
+
this.ctx.profiler = this.ctx.profiler || {};
|
|
4184
|
+
if (action) {
|
|
4185
|
+
let startTime = this.ctx.profiler[action] ? Date.now() - this.ctx.profiler[action] : this.startTime;
|
|
4186
|
+
this.ctx.profiler[action] = Date.now() - startTime;
|
|
4187
|
+
}
|
|
4188
|
+
this.ctx.profiler.totalTime = Date.now() - this.absaluteStartTime;
|
|
4189
|
+
if (!options.continue) this.startTime = Date.now();
|
|
4190
|
+
return this;
|
|
4191
|
+
}
|
|
4172
4192
|
}
|
|
4173
4193
|
export {
|
|
4174
4194
|
DatadogLogger
|
package/dist/browser.umd.js
CHANGED
|
@@ -4131,6 +4131,14 @@
|
|
|
4131
4131
|
forwardErrorsToLogs: false,
|
|
4132
4132
|
sessionSampleRate: 100
|
|
4133
4133
|
};
|
|
4134
|
+
const connection = () => {
|
|
4135
|
+
var _a2, _b, _c, _d, _e, _f;
|
|
4136
|
+
return {
|
|
4137
|
+
downlink: (_b = (_a2 = window == null ? void 0 : window.navigator) == null ? void 0 : _a2.connection) == null ? void 0 : _b.downlink,
|
|
4138
|
+
effectiveType: (_d = (_c = window == null ? void 0 : window.navigator) == null ? void 0 : _c.connection) == null ? void 0 : _d.effectiveType,
|
|
4139
|
+
rtt: (_f = (_e = window == null ? void 0 : window.navigator) == null ? void 0 : _e.connection) == null ? void 0 : _f.rtt
|
|
4140
|
+
};
|
|
4141
|
+
};
|
|
4134
4142
|
class DatadogLogger {
|
|
4135
4143
|
constructor(options = {}) {
|
|
4136
4144
|
if (!options.clientToken) {
|
|
@@ -4152,18 +4160,20 @@
|
|
|
4152
4160
|
this.options = options;
|
|
4153
4161
|
this.logger = datadogLogs.logger;
|
|
4154
4162
|
this.ctx = {};
|
|
4163
|
+
this.startTime = Date.now();
|
|
4164
|
+
this.absaluteStartTime = Date.now();
|
|
4155
4165
|
}
|
|
4156
4166
|
log() {
|
|
4157
4167
|
let normalized = normalizeArgs(...arguments);
|
|
4158
|
-
this.logger.log(normalized.message, Object.assign(normalized.properties, this.ctx));
|
|
4168
|
+
this.logger.log(normalized.message, Object.assign(normalized.properties, { connection: connection() }, this.ctx));
|
|
4159
4169
|
}
|
|
4160
4170
|
info() {
|
|
4161
4171
|
let normalized = normalizeArgs(...arguments);
|
|
4162
|
-
this.logger.info(normalized.message, Object.assign(normalized.properties, this.ctx));
|
|
4172
|
+
this.logger.info(normalized.message, Object.assign(normalized.properties, { connection: connection() }, this.ctx));
|
|
4163
4173
|
}
|
|
4164
4174
|
error() {
|
|
4165
4175
|
let normalized = normalizeArgs(...arguments);
|
|
4166
|
-
this.logger.error(normalized.message, Object.assign(normalized.properties, this.ctx), normalized.error);
|
|
4176
|
+
this.logger.error(normalized.message, Object.assign(normalized.properties, { connection: connection() }, this.ctx), normalized.error);
|
|
4167
4177
|
}
|
|
4168
4178
|
context(key, value) {
|
|
4169
4179
|
if (typeof key === "string") {
|
|
@@ -4173,6 +4183,16 @@
|
|
|
4173
4183
|
}
|
|
4174
4184
|
return this;
|
|
4175
4185
|
}
|
|
4186
|
+
profile(action, options = {}) {
|
|
4187
|
+
this.ctx.profiler = this.ctx.profiler || {};
|
|
4188
|
+
if (action) {
|
|
4189
|
+
let startTime = this.ctx.profiler[action] ? Date.now() - this.ctx.profiler[action] : this.startTime;
|
|
4190
|
+
this.ctx.profiler[action] = Date.now() - startTime;
|
|
4191
|
+
}
|
|
4192
|
+
this.ctx.profiler.totalTime = Date.now() - this.absaluteStartTime;
|
|
4193
|
+
if (!options.continue) this.startTime = Date.now();
|
|
4194
|
+
return this;
|
|
4195
|
+
}
|
|
4176
4196
|
}
|
|
4177
4197
|
exports2.DatadogLogger = DatadogLogger;
|
|
4178
4198
|
Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
|
package/dist/index.es.js
CHANGED
|
@@ -293,6 +293,20 @@ class BaseLogger {
|
|
|
293
293
|
this.logger.error(...arguments, this.ctx);
|
|
294
294
|
this._stopMemProfile();
|
|
295
295
|
}
|
|
296
|
+
warn() {
|
|
297
|
+
if (arguments.length > 0 && this._shouldExclude(arguments[0])) {
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
this.logger.warn(...arguments, this.ctx);
|
|
301
|
+
this._stopMemProfile();
|
|
302
|
+
}
|
|
303
|
+
debug() {
|
|
304
|
+
if (arguments.length > 0 && this._shouldExclude(arguments[0])) {
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
this.logger.debug(...arguments, this.ctx);
|
|
308
|
+
this._stopMemProfile();
|
|
309
|
+
}
|
|
296
310
|
profile(action, options = {}) {
|
|
297
311
|
this.ctx.profiler = this.ctx.profiler || {};
|
|
298
312
|
if (action) {
|
|
@@ -628,19 +642,34 @@ class StaticLogger extends BaseLogger {
|
|
|
628
642
|
options.console = false;
|
|
629
643
|
super("console", options);
|
|
630
644
|
}
|
|
631
|
-
|
|
632
|
-
console
|
|
645
|
+
_log(level, args) {
|
|
646
|
+
console[level](...args);
|
|
633
647
|
let message = "";
|
|
634
|
-
Array.from(
|
|
648
|
+
Array.from(args).forEach((arg) => {
|
|
635
649
|
if (typeof arg === "object" && !Array.isArray(arg)) {
|
|
636
650
|
Object.assign(this.ctx, arg);
|
|
637
651
|
} else {
|
|
638
652
|
message += ` ${arg}`;
|
|
639
653
|
}
|
|
640
654
|
});
|
|
641
|
-
this.logger
|
|
655
|
+
this.logger[level](message.trim(), this.ctx);
|
|
642
656
|
this.ctx = {};
|
|
643
657
|
}
|
|
658
|
+
log() {
|
|
659
|
+
this._log("info", arguments);
|
|
660
|
+
}
|
|
661
|
+
info() {
|
|
662
|
+
this._log("info", arguments);
|
|
663
|
+
}
|
|
664
|
+
warn() {
|
|
665
|
+
this._log("warn", arguments);
|
|
666
|
+
}
|
|
667
|
+
error() {
|
|
668
|
+
this._log("error", arguments);
|
|
669
|
+
}
|
|
670
|
+
debug() {
|
|
671
|
+
this._log("debug", arguments);
|
|
672
|
+
}
|
|
644
673
|
}
|
|
645
674
|
const staticLogger = new StaticLogger();
|
|
646
675
|
export {
|
package/dist/index.umd.js
CHANGED
|
@@ -297,6 +297,20 @@
|
|
|
297
297
|
this.logger.error(...arguments, this.ctx);
|
|
298
298
|
this._stopMemProfile();
|
|
299
299
|
}
|
|
300
|
+
warn() {
|
|
301
|
+
if (arguments.length > 0 && this._shouldExclude(arguments[0])) {
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
this.logger.warn(...arguments, this.ctx);
|
|
305
|
+
this._stopMemProfile();
|
|
306
|
+
}
|
|
307
|
+
debug() {
|
|
308
|
+
if (arguments.length > 0 && this._shouldExclude(arguments[0])) {
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
this.logger.debug(...arguments, this.ctx);
|
|
312
|
+
this._stopMemProfile();
|
|
313
|
+
}
|
|
300
314
|
profile(action, options = {}) {
|
|
301
315
|
this.ctx.profiler = this.ctx.profiler || {};
|
|
302
316
|
if (action) {
|
|
@@ -632,19 +646,34 @@
|
|
|
632
646
|
options.console = false;
|
|
633
647
|
super("console", options);
|
|
634
648
|
}
|
|
635
|
-
|
|
636
|
-
console
|
|
649
|
+
_log(level, args) {
|
|
650
|
+
console[level](...args);
|
|
637
651
|
let message = "";
|
|
638
|
-
Array.from(
|
|
652
|
+
Array.from(args).forEach((arg) => {
|
|
639
653
|
if (typeof arg === "object" && !Array.isArray(arg)) {
|
|
640
654
|
Object.assign(this.ctx, arg);
|
|
641
655
|
} else {
|
|
642
656
|
message += ` ${arg}`;
|
|
643
657
|
}
|
|
644
658
|
});
|
|
645
|
-
this.logger
|
|
659
|
+
this.logger[level](message.trim(), this.ctx);
|
|
646
660
|
this.ctx = {};
|
|
647
661
|
}
|
|
662
|
+
log() {
|
|
663
|
+
this._log("info", arguments);
|
|
664
|
+
}
|
|
665
|
+
info() {
|
|
666
|
+
this._log("info", arguments);
|
|
667
|
+
}
|
|
668
|
+
warn() {
|
|
669
|
+
this._log("warn", arguments);
|
|
670
|
+
}
|
|
671
|
+
error() {
|
|
672
|
+
this._log("error", arguments);
|
|
673
|
+
}
|
|
674
|
+
debug() {
|
|
675
|
+
this._log("debug", arguments);
|
|
676
|
+
}
|
|
648
677
|
}
|
|
649
678
|
const staticLogger = new StaticLogger();
|
|
650
679
|
exports2.BaseLogger = BaseLogger;
|