mynth-logger 1.0.6 → 1.0.7
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.
|
@@ -1,27 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.setupLogging = void 0;
|
|
7
|
-
var json5_1 = __importDefault(require("json5"));
|
|
8
|
-
var pino_1 = __importDefault(require("pino"));
|
|
9
|
-
var isPinoPrettyInstalled = function () {
|
|
1
|
+
import JSON5 from "json5";
|
|
2
|
+
import pino from "pino";
|
|
3
|
+
const isPinoPrettyInstalled = () => {
|
|
10
4
|
try {
|
|
11
|
-
(
|
|
5
|
+
pino({ transport: { target: "pino-pretty" } });
|
|
12
6
|
return true;
|
|
13
7
|
}
|
|
14
|
-
catch
|
|
8
|
+
catch {
|
|
15
9
|
return false;
|
|
16
10
|
}
|
|
17
11
|
};
|
|
18
|
-
|
|
12
|
+
const pinoSettings = {
|
|
19
13
|
base: undefined,
|
|
20
14
|
timestamp: false,
|
|
21
15
|
level: "debug",
|
|
22
16
|
formatters: {
|
|
23
|
-
level
|
|
24
|
-
return { level
|
|
17
|
+
level(level) {
|
|
18
|
+
return { level };
|
|
25
19
|
},
|
|
26
20
|
},
|
|
27
21
|
};
|
|
@@ -33,20 +27,20 @@ if (isPinoPrettyInstalled() && process.env.NODE_ENV != "test") {
|
|
|
33
27
|
},
|
|
34
28
|
};
|
|
35
29
|
}
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
const logger = pino(pinoSettings);
|
|
31
|
+
const formatItem = (item) => {
|
|
38
32
|
// Remove colors from strings
|
|
39
33
|
if (typeof item === "string") {
|
|
40
34
|
return item.replace(/\x1b\[[0-9;]*m/g, "");
|
|
41
35
|
}
|
|
42
|
-
return
|
|
36
|
+
return JSON5.stringify(item).replace(/^\'|\'$/g, "");
|
|
43
37
|
};
|
|
44
|
-
|
|
38
|
+
const format = (items) => {
|
|
45
39
|
return Array.from(items)
|
|
46
|
-
.map(
|
|
40
|
+
.map((item) => formatItem(item))
|
|
47
41
|
.join(" ");
|
|
48
42
|
};
|
|
49
|
-
|
|
43
|
+
const setupLogging = () => {
|
|
50
44
|
if (typeof window !== "undefined")
|
|
51
45
|
return;
|
|
52
46
|
console.log = function () {
|
|
@@ -65,4 +59,4 @@ var setupLogging = function () {
|
|
|
65
59
|
logger.debug(format(Array.from(arguments)));
|
|
66
60
|
};
|
|
67
61
|
};
|
|
68
|
-
|
|
62
|
+
export { setupLogging };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mynth-logger",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "Package to format logs for mynth microservices.",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "dist/index.js",
|
|
7
|
-
"
|
|
6
|
+
"main": "dist/src/index.js",
|
|
7
|
+
"typings": "dist/src/index.d.ts",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"test": "npx ava",
|
|
10
10
|
"build": "npx tsc",
|
package/src/index.d.ts
ADDED
package/tsconfig.json
CHANGED
|
@@ -1,25 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"baseUrl": "
|
|
4
|
-
"target": "
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"strict":
|
|
3
|
+
"baseUrl": "./",
|
|
4
|
+
"target": "es2020",
|
|
5
|
+
"module": "es2022",
|
|
6
|
+
"moduleResolution": "Node",
|
|
7
|
+
"strict": true,
|
|
8
8
|
"esModuleInterop": true,
|
|
9
9
|
"skipLibCheck": true,
|
|
10
|
-
"
|
|
10
|
+
"forceConsistentCasingInFileNames": true,
|
|
11
11
|
"outDir": "./dist",
|
|
12
|
-
"rootDir": "./src",
|
|
13
12
|
"declaration": true,
|
|
14
|
-
"
|
|
15
|
-
"paths": {
|
|
16
|
-
"src": ["./src"]
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
"include": ["src/**/*"],
|
|
20
|
-
"exclude": ["node_modules", "dist", "build"],
|
|
21
|
-
"ts-node": {
|
|
22
|
-
"transpileOnly": true,
|
|
23
|
-
"swc": true
|
|
13
|
+
"declarationDir": "dist"
|
|
24
14
|
}
|
|
25
15
|
}
|
|
File without changes
|