infront-logger 1.1.13 → 1.1.15

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.
@@ -4148,6 +4148,8 @@ class DatadogLogger {
4148
4148
  this.options = options;
4149
4149
  this.logger = datadogLogs.logger;
4150
4150
  this.ctx = {};
4151
+ this.startTime = Date.now();
4152
+ this.absaluteStartTime = Date.now();
4151
4153
  }
4152
4154
  log() {
4153
4155
  let normalized = normalizeArgs(...arguments);
@@ -4169,6 +4171,16 @@ class DatadogLogger {
4169
4171
  }
4170
4172
  return this;
4171
4173
  }
4174
+ profile(action, options = {}) {
4175
+ this.ctx.profiler = this.ctx.profiler || {};
4176
+ if (action) {
4177
+ let startTime = this.ctx.profiler[action] ? Date.now() - this.ctx.profiler[action] : this.startTime;
4178
+ this.ctx.profiler[action] = Date.now() - startTime;
4179
+ }
4180
+ this.ctx.profiler.totalTime = Date.now() - this.absaluteStartTime;
4181
+ if (!options.continue) this.startTime = Date.now();
4182
+ return this;
4183
+ }
4172
4184
  }
4173
4185
  export {
4174
4186
  DatadogLogger
@@ -4152,6 +4152,8 @@
4152
4152
  this.options = options;
4153
4153
  this.logger = datadogLogs.logger;
4154
4154
  this.ctx = {};
4155
+ this.startTime = Date.now();
4156
+ this.absaluteStartTime = Date.now();
4155
4157
  }
4156
4158
  log() {
4157
4159
  let normalized = normalizeArgs(...arguments);
@@ -4173,6 +4175,16 @@
4173
4175
  }
4174
4176
  return this;
4175
4177
  }
4178
+ profile(action, options = {}) {
4179
+ this.ctx.profiler = this.ctx.profiler || {};
4180
+ if (action) {
4181
+ let startTime = this.ctx.profiler[action] ? Date.now() - this.ctx.profiler[action] : this.startTime;
4182
+ this.ctx.profiler[action] = Date.now() - startTime;
4183
+ }
4184
+ this.ctx.profiler.totalTime = Date.now() - this.absaluteStartTime;
4185
+ if (!options.continue) this.startTime = Date.now();
4186
+ return this;
4187
+ }
4176
4188
  }
4177
4189
  exports2.DatadogLogger = DatadogLogger;
4178
4190
  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
- log() {
632
- console.log(...arguments);
645
+ _log(level, args) {
646
+ console[level](...args);
633
647
  let message = "";
634
- Array.from(arguments).forEach((arg) => {
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.info(message.trim(), this.ctx);
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
- log() {
636
- console.log(...arguments);
649
+ _log(level, args) {
650
+ console[level](...args);
637
651
  let message = "";
638
- Array.from(arguments).forEach((arg) => {
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.info(message.trim(), this.ctx);
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "infront-logger",
3
- "version": "1.1.13",
3
+ "version": "1.1.15",
4
4
  "description": "",
5
5
  "files": [
6
6
  "dist"