mynth-logger 1.0.6 → 1.0.8
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.
|
@@ -4,24 +4,24 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.setupLogging = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
const json5_1 = __importDefault(require("json5"));
|
|
8
|
+
const pino_1 = __importDefault(require("pino"));
|
|
9
|
+
const isPinoPrettyInstalled = () => {
|
|
10
10
|
try {
|
|
11
11
|
(0, pino_1.default)({ transport: { target: "pino-pretty" } });
|
|
12
12
|
return true;
|
|
13
13
|
}
|
|
14
|
-
catch
|
|
14
|
+
catch {
|
|
15
15
|
return false;
|
|
16
16
|
}
|
|
17
17
|
};
|
|
18
|
-
|
|
18
|
+
const pinoSettings = {
|
|
19
19
|
base: undefined,
|
|
20
20
|
timestamp: false,
|
|
21
21
|
level: "debug",
|
|
22
22
|
formatters: {
|
|
23
|
-
level
|
|
24
|
-
return { level
|
|
23
|
+
level(level) {
|
|
24
|
+
return { level };
|
|
25
25
|
},
|
|
26
26
|
},
|
|
27
27
|
};
|
|
@@ -33,20 +33,20 @@ if (isPinoPrettyInstalled() && process.env.NODE_ENV != "test") {
|
|
|
33
33
|
},
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
const logger = (0, pino_1.default)(pinoSettings);
|
|
37
|
+
const formatItem = (item) => {
|
|
38
38
|
// Remove colors from strings
|
|
39
39
|
if (typeof item === "string") {
|
|
40
40
|
return item.replace(/\x1b\[[0-9;]*m/g, "");
|
|
41
41
|
}
|
|
42
42
|
return json5_1.default.stringify(item).replace(/^\'|\'$/g, "");
|
|
43
43
|
};
|
|
44
|
-
|
|
44
|
+
const format = (items) => {
|
|
45
45
|
return Array.from(items)
|
|
46
|
-
.map(
|
|
46
|
+
.map((item) => formatItem(item))
|
|
47
47
|
.join(" ");
|
|
48
48
|
};
|
|
49
|
-
|
|
49
|
+
const setupLogging = () => {
|
|
50
50
|
if (typeof window !== "undefined")
|
|
51
51
|
return;
|
|
52
52
|
console.log = function () {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const ava_1 = __importDefault(require("ava"));
|
|
7
|
+
const index_1 = require("../src/index");
|
|
8
|
+
(0, ava_1.default)("setupLogging can be called", (t) => {
|
|
9
|
+
(0, index_1.setupLogging)();
|
|
10
|
+
console.debug("Hello ava");
|
|
11
|
+
t.pass();
|
|
12
|
+
});
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mynth-logger",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
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": "es2022",
|
|
5
|
+
"module": "CommonJS",
|
|
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
|