infront-logger 1.1.4 → 1.1.5

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/index.es.js CHANGED
@@ -427,7 +427,8 @@ class MongooseLogger extends BaseLogger {
427
427
  }
428
428
  async explain(query) {
429
429
  if (this.options.explain && !query.options.explain) {
430
- this.ctx.explain = await query.clone().explain();
430
+ let { command, executionStats, queryPlanner } = await query.clone().explain();
431
+ this.ctx.explain = { command, executionStats, queryPlanner };
431
432
  }
432
433
  }
433
434
  result(res) {
@@ -454,6 +455,15 @@ async function postHook(target, res) {
454
455
  return;
455
456
  const op = target.constructor.name === "Aggregate" ? "aggregate" : target.op || target.$op;
456
457
  const collection = ((_b = target == null ? void 0 : target._collection) == null ? void 0 : _b.collectionName) || ((_c = target == null ? void 0 : target.collection) == null ? void 0 : _c.name) || ((_e = (_d = target == null ? void 0 : target._model) == null ? void 0 : _d.collection) == null ? void 0 : _e.collectionName);
458
+ if (!op || !collection) {
459
+ try {
460
+ let { logger, ...t } = target;
461
+ target == null ? void 0 : target.logger.profile().result(res).context("target", t).info(`DB query with bad target}`);
462
+ } catch (err) {
463
+ console.error(err);
464
+ }
465
+ return;
466
+ }
457
467
  (_f = target == null ? void 0 : target.logger) == null ? void 0 : _f.operation(op).collection(collection).query(target._conditions).update(target._update).pipeline(target._pipeline).profile().result(res);
458
468
  if (explained.includes(op)) {
459
469
  await (target == null ? void 0 : target.logger.explain(target));
package/dist/index.umd.js CHANGED
@@ -431,7 +431,8 @@
431
431
  }
432
432
  async explain(query) {
433
433
  if (this.options.explain && !query.options.explain) {
434
- this.ctx.explain = await query.clone().explain();
434
+ let { command, executionStats, queryPlanner } = await query.clone().explain();
435
+ this.ctx.explain = { command, executionStats, queryPlanner };
435
436
  }
436
437
  }
437
438
  result(res) {
@@ -458,6 +459,15 @@
458
459
  return;
459
460
  const op = target.constructor.name === "Aggregate" ? "aggregate" : target.op || target.$op;
460
461
  const collection = ((_b = target == null ? void 0 : target._collection) == null ? void 0 : _b.collectionName) || ((_c = target == null ? void 0 : target.collection) == null ? void 0 : _c.name) || ((_e = (_d = target == null ? void 0 : target._model) == null ? void 0 : _d.collection) == null ? void 0 : _e.collectionName);
462
+ if (!op || !collection) {
463
+ try {
464
+ let { logger, ...t } = target;
465
+ target == null ? void 0 : target.logger.profile().result(res).context("target", t).info(`DB query with bad target}`);
466
+ } catch (err) {
467
+ console.error(err);
468
+ }
469
+ return;
470
+ }
461
471
  (_f = target == null ? void 0 : target.logger) == null ? void 0 : _f.operation(op).collection(collection).query(target._conditions).update(target._update).pipeline(target._pipeline).profile().result(res);
462
472
  if (explained.includes(op)) {
463
473
  await (target == null ? void 0 : target.logger.explain(target));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "infront-logger",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
4
  "description": "",
5
5
  "files": [
6
6
  "dist"