infront-logger 1.1.16 → 1.1.17
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 +2 -4
- package/dist/browser.umd.js +2 -4
- package/dist/index.es.js +11 -7
- package/dist/index.umd.js +11 -7
- package/package.json +17 -17
package/dist/browser.es.js
CHANGED
|
@@ -3279,8 +3279,7 @@ var __decorate = function(decorators, target, key, desc) {
|
|
|
3279
3279
|
};
|
|
3280
3280
|
var HandlerType = {
|
|
3281
3281
|
console: "console",
|
|
3282
|
-
http: "http"
|
|
3283
|
-
silent: "silent"
|
|
3282
|
+
http: "http"
|
|
3284
3283
|
};
|
|
3285
3284
|
var STATUSES = Object.keys(StatusType);
|
|
3286
3285
|
var Logger = (
|
|
@@ -3891,8 +3890,7 @@ function truncateResponseStream(stream, bytesLimit, callback) {
|
|
|
3891
3890
|
callback(void 0, responseText);
|
|
3892
3891
|
}
|
|
3893
3892
|
}, {
|
|
3894
|
-
bytesLimit
|
|
3895
|
-
collectStreamBody: true
|
|
3893
|
+
bytesLimit
|
|
3896
3894
|
});
|
|
3897
3895
|
}
|
|
3898
3896
|
function startRuntimeErrorCollection(configuration, lifeCycle) {
|
package/dist/browser.umd.js
CHANGED
|
@@ -3283,8 +3283,7 @@
|
|
|
3283
3283
|
};
|
|
3284
3284
|
var HandlerType = {
|
|
3285
3285
|
console: "console",
|
|
3286
|
-
http: "http"
|
|
3287
|
-
silent: "silent"
|
|
3286
|
+
http: "http"
|
|
3288
3287
|
};
|
|
3289
3288
|
var STATUSES = Object.keys(StatusType);
|
|
3290
3289
|
var Logger = (
|
|
@@ -3895,8 +3894,7 @@
|
|
|
3895
3894
|
callback(void 0, responseText);
|
|
3896
3895
|
}
|
|
3897
3896
|
}, {
|
|
3898
|
-
bytesLimit
|
|
3899
|
-
collectStreamBody: true
|
|
3897
|
+
bytesLimit
|
|
3900
3898
|
});
|
|
3901
3899
|
}
|
|
3902
3900
|
function startRuntimeErrorCollection(configuration, lifeCycle) {
|
package/dist/index.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require("winston-daily-rotate-file");
|
|
2
2
|
const { format: format$1, createLogger, transports, addColors } = require("winston");
|
|
3
|
-
require("util");
|
|
3
|
+
const { inspect } = require("util");
|
|
4
4
|
const colors = {
|
|
5
5
|
error: "red",
|
|
6
6
|
warn: "yellow",
|
|
@@ -186,8 +186,7 @@ function bytesToMB$1(b) {
|
|
|
186
186
|
return toFixedNumber(b / 1024 / 1024, 2, 10);
|
|
187
187
|
}
|
|
188
188
|
function formatBytes$2(bytes, decimals = 2) {
|
|
189
|
-
if (!+bytes)
|
|
190
|
-
return "0 Bytes";
|
|
189
|
+
if (!+bytes) return "0 Bytes";
|
|
191
190
|
const k = 1024;
|
|
192
191
|
const dm = decimals < 0 ? 0 : decimals;
|
|
193
192
|
const sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
|
@@ -441,7 +440,8 @@ const explained = [
|
|
|
441
440
|
const OPTIONS = {
|
|
442
441
|
maxResBytes: 100 * 1024,
|
|
443
442
|
logRes: true,
|
|
444
|
-
explain: false
|
|
443
|
+
explain: false,
|
|
444
|
+
sampleRate: 1
|
|
445
445
|
};
|
|
446
446
|
class MongooseLogger extends BaseLogger {
|
|
447
447
|
constructor(options = {}) {
|
|
@@ -491,7 +491,7 @@ class MongooseLogger extends BaseLogger {
|
|
|
491
491
|
}
|
|
492
492
|
}
|
|
493
493
|
async function postHook(target, res) {
|
|
494
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
494
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
495
495
|
if ((_a = target == null ? void 0 : target.options) == null ? void 0 : _a.explain) return;
|
|
496
496
|
const op = target.constructor.name === "Aggregate" ? "aggregate" : target.op || target.$op;
|
|
497
497
|
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);
|
|
@@ -504,11 +504,15 @@ async function postHook(target, res) {
|
|
|
504
504
|
}
|
|
505
505
|
return;
|
|
506
506
|
}
|
|
507
|
-
(_f = target == null ? void 0 : target.logger) == null ? void 0 : _f.
|
|
507
|
+
const sampleRate = ((_g = (_f = target == null ? void 0 : target.logger) == null ? void 0 : _f.options) == null ? void 0 : _g.sampleRate) ?? 1;
|
|
508
|
+
if (sampleRate < 1 && Math.random() >= sampleRate) {
|
|
509
|
+
return;
|
|
510
|
+
}
|
|
511
|
+
(_h = target == null ? void 0 : target.logger) == null ? void 0 : _h.operation(op).collection(collection).query(target._conditions).update(target._update).pipeline(target._pipeline).profile().result(res);
|
|
508
512
|
if (explained.includes(op)) {
|
|
509
513
|
await (target == null ? void 0 : target.logger.explain(target));
|
|
510
514
|
}
|
|
511
|
-
(
|
|
515
|
+
(_i = target == null ? void 0 : target.logger) == null ? void 0 : _i.info(`DB query: ${op} - ${collection}`);
|
|
512
516
|
}
|
|
513
517
|
function plugin(options = {}) {
|
|
514
518
|
return (schema) => {
|
package/dist/index.umd.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"use strict";
|
|
5
5
|
require("winston-daily-rotate-file");
|
|
6
6
|
const { format: format$1, createLogger, transports, addColors } = require("winston");
|
|
7
|
-
require("util");
|
|
7
|
+
const { inspect } = require("util");
|
|
8
8
|
const colors = {
|
|
9
9
|
error: "red",
|
|
10
10
|
warn: "yellow",
|
|
@@ -190,8 +190,7 @@
|
|
|
190
190
|
return toFixedNumber(b / 1024 / 1024, 2, 10);
|
|
191
191
|
}
|
|
192
192
|
function formatBytes$2(bytes, decimals = 2) {
|
|
193
|
-
if (!+bytes)
|
|
194
|
-
return "0 Bytes";
|
|
193
|
+
if (!+bytes) return "0 Bytes";
|
|
195
194
|
const k = 1024;
|
|
196
195
|
const dm = decimals < 0 ? 0 : decimals;
|
|
197
196
|
const sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
|
@@ -445,7 +444,8 @@
|
|
|
445
444
|
const OPTIONS = {
|
|
446
445
|
maxResBytes: 100 * 1024,
|
|
447
446
|
logRes: true,
|
|
448
|
-
explain: false
|
|
447
|
+
explain: false,
|
|
448
|
+
sampleRate: 1
|
|
449
449
|
};
|
|
450
450
|
class MongooseLogger extends BaseLogger {
|
|
451
451
|
constructor(options = {}) {
|
|
@@ -495,7 +495,7 @@
|
|
|
495
495
|
}
|
|
496
496
|
}
|
|
497
497
|
async function postHook(target, res) {
|
|
498
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
498
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
499
499
|
if ((_a = target == null ? void 0 : target.options) == null ? void 0 : _a.explain) return;
|
|
500
500
|
const op = target.constructor.name === "Aggregate" ? "aggregate" : target.op || target.$op;
|
|
501
501
|
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);
|
|
@@ -508,11 +508,15 @@
|
|
|
508
508
|
}
|
|
509
509
|
return;
|
|
510
510
|
}
|
|
511
|
-
(_f = target == null ? void 0 : target.logger) == null ? void 0 : _f.
|
|
511
|
+
const sampleRate = ((_g = (_f = target == null ? void 0 : target.logger) == null ? void 0 : _f.options) == null ? void 0 : _g.sampleRate) ?? 1;
|
|
512
|
+
if (sampleRate < 1 && Math.random() >= sampleRate) {
|
|
513
|
+
return;
|
|
514
|
+
}
|
|
515
|
+
(_h = target == null ? void 0 : target.logger) == null ? void 0 : _h.operation(op).collection(collection).query(target._conditions).update(target._update).pipeline(target._pipeline).profile().result(res);
|
|
512
516
|
if (explained.includes(op)) {
|
|
513
517
|
await (target == null ? void 0 : target.logger.explain(target));
|
|
514
518
|
}
|
|
515
|
-
(
|
|
519
|
+
(_i = target == null ? void 0 : target.logger) == null ? void 0 : _i.info(`DB query: ${op} - ${collection}`);
|
|
516
520
|
}
|
|
517
521
|
function plugin(options = {}) {
|
|
518
522
|
return (schema) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "infront-logger",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.17",
|
|
4
4
|
"description": "",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -18,6 +18,19 @@
|
|
|
18
18
|
"require": "./dist/browser.umd.js"
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
23
|
+
"version:patch": "npm version patch",
|
|
24
|
+
"dev": "vite",
|
|
25
|
+
"build:node": "vite build",
|
|
26
|
+
"build:node:watch": "vite build --watch",
|
|
27
|
+
"build:browser:watch": "vite build --config vite.config.browser.js --watch",
|
|
28
|
+
"build:watch": "concurrently \"npm run build:node:watch\" \"npm run build:browser:watch\"",
|
|
29
|
+
"preview": "vite preview",
|
|
30
|
+
"build:browser": " vite build --config vite.config.browser.js",
|
|
31
|
+
"build": "concurrently \"npm run build:node\" \"npm run build:browser\"",
|
|
32
|
+
"prebuild": "rimraf --glob dist/*"
|
|
33
|
+
},
|
|
21
34
|
"keywords": [],
|
|
22
35
|
"author": "",
|
|
23
36
|
"license": "ISC",
|
|
@@ -31,21 +44,8 @@
|
|
|
31
44
|
},
|
|
32
45
|
"dependencies": {
|
|
33
46
|
"@datadog/browser-logs": "~5.23.3",
|
|
47
|
+
"infront-utils": "~1.0.14",
|
|
34
48
|
"winston": "^3.11.0",
|
|
35
|
-
"winston-daily-rotate-file": "^4.7.1"
|
|
36
|
-
"infront-utils": "^1.0.1"
|
|
37
|
-
},
|
|
38
|
-
"scripts": {
|
|
39
|
-
"test": "echo \"Error: no test specified\" && exit 1",
|
|
40
|
-
"version:patch": "npm version patch",
|
|
41
|
-
"dev": "vite",
|
|
42
|
-
"build:node": "vite build",
|
|
43
|
-
"build:node:watch": "vite build --watch",
|
|
44
|
-
"build:browser:watch": "vite build --config vite.config.browser.js --watch",
|
|
45
|
-
"build:watch": "concurrently \"npm run build:node:watch\" \"npm run build:browser:watch\"",
|
|
46
|
-
"preview": "vite preview",
|
|
47
|
-
"build:browser": " vite build --config vite.config.browser.js",
|
|
48
|
-
"build": "concurrently \"npm run build:node\" \"npm run build:browser\"",
|
|
49
|
-
"prebuild": "rimraf --glob dist/*"
|
|
49
|
+
"winston-daily-rotate-file": "^4.7.1"
|
|
50
50
|
}
|
|
51
|
-
}
|
|
51
|
+
}
|