infront-logger 1.1.1 → 1.1.2

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
@@ -9,7 +9,7 @@ const colors = {
9
9
  debug: "white"
10
10
  };
11
11
  addColors(colors);
12
- const OPTIONS = {
12
+ const OPTIONS$1 = {
13
13
  dirname: "logs",
14
14
  levels: {
15
15
  error: 0,
@@ -101,7 +101,7 @@ function createTransport(options) {
101
101
  }
102
102
  class Logger {
103
103
  constructor(options = {}) {
104
- this.options = { ...OPTIONS, ...options };
104
+ this.options = { ...OPTIONS$1, ...options };
105
105
  if (!this.options.filename.includes("."))
106
106
  this.options.filename += ".log";
107
107
  if (!this.options.errorFilename.includes("."))
@@ -241,6 +241,7 @@ function stats() {
241
241
  }
242
242
  class BaseLogger {
243
243
  constructor(component, options) {
244
+ this.options = options;
244
245
  this.logger = new Logger(options).logger.child({ component });
245
246
  this.ctx = {};
246
247
  this.startTime = Date.now();
@@ -391,10 +392,13 @@ const ops = [
391
392
  "aggregate",
392
393
  "save"
393
394
  ];
394
- const MAX_RESULT_BYTES = 100 * 1024;
395
+ const OPTIONS = {
396
+ maxResBytes: 100 * 1024,
397
+ logRes: true
398
+ };
395
399
  class MongooseLogger extends BaseLogger {
396
400
  constructor(options = {}) {
397
- super("database", options);
401
+ super("database", { ...OPTIONS, ...options });
398
402
  }
399
403
  operation(o) {
400
404
  this.ctx.operation = o;
@@ -421,12 +425,14 @@ class MongooseLogger extends BaseLogger {
421
425
  this.ctx.resultSizeBytes = JSON.stringify(res).length;
422
426
  } catch (err) {
423
427
  }
428
+ if (!this.options.logRes)
429
+ return this;
424
430
  if (Array.isArray(res)) {
425
431
  this.ctx.documentCount = res.length;
426
- } else if (this.ctx.resultSizeBytes < MAX_RESULT_BYTES) {
432
+ } else if (this.ctx.resultSizeBytes < this.options.maxResBytes) {
427
433
  this.ctx.result = res;
428
434
  } else {
429
- this.ctx.result = `Result too long (more then ${MAX_RESULT_BYTES} bytes)`;
435
+ this.ctx.result = `Result too long (more then ${this.options.maxResBytes} bytes)`;
430
436
  }
431
437
  return this;
432
438
  }
package/dist/index.umd.js CHANGED
@@ -13,7 +13,7 @@
13
13
  debug: "white"
14
14
  };
15
15
  addColors(colors);
16
- const OPTIONS = {
16
+ const OPTIONS$1 = {
17
17
  dirname: "logs",
18
18
  levels: {
19
19
  error: 0,
@@ -105,7 +105,7 @@
105
105
  }
106
106
  class Logger {
107
107
  constructor(options = {}) {
108
- this.options = { ...OPTIONS, ...options };
108
+ this.options = { ...OPTIONS$1, ...options };
109
109
  if (!this.options.filename.includes("."))
110
110
  this.options.filename += ".log";
111
111
  if (!this.options.errorFilename.includes("."))
@@ -245,6 +245,7 @@
245
245
  }
246
246
  class BaseLogger {
247
247
  constructor(component, options) {
248
+ this.options = options;
248
249
  this.logger = new Logger(options).logger.child({ component });
249
250
  this.ctx = {};
250
251
  this.startTime = Date.now();
@@ -395,10 +396,13 @@
395
396
  "aggregate",
396
397
  "save"
397
398
  ];
398
- const MAX_RESULT_BYTES = 100 * 1024;
399
+ const OPTIONS = {
400
+ maxResBytes: 100 * 1024,
401
+ logRes: true
402
+ };
399
403
  class MongooseLogger extends BaseLogger {
400
404
  constructor(options = {}) {
401
- super("database", options);
405
+ super("database", { ...OPTIONS, ...options });
402
406
  }
403
407
  operation(o) {
404
408
  this.ctx.operation = o;
@@ -425,12 +429,14 @@
425
429
  this.ctx.resultSizeBytes = JSON.stringify(res).length;
426
430
  } catch (err) {
427
431
  }
432
+ if (!this.options.logRes)
433
+ return this;
428
434
  if (Array.isArray(res)) {
429
435
  this.ctx.documentCount = res.length;
430
- } else if (this.ctx.resultSizeBytes < MAX_RESULT_BYTES) {
436
+ } else if (this.ctx.resultSizeBytes < this.options.maxResBytes) {
431
437
  this.ctx.result = res;
432
438
  } else {
433
- this.ctx.result = `Result too long (more then ${MAX_RESULT_BYTES} bytes)`;
439
+ this.ctx.result = `Result too long (more then ${this.options.maxResBytes} bytes)`;
434
440
  }
435
441
  return this;
436
442
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "infront-logger",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "",
5
5
  "files": [
6
6
  "dist"