@emartech/json-logger 6.0.1 → 7.0.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/.github/workflows/main.yml +33 -0
- package/dist/config.d.ts +0 -1
- package/dist/config.js +5 -13
- package/dist/formatter/index.d.ts +0 -2
- package/dist/formatter/index.js +0 -2
- package/dist/index.d.ts +0 -1
- package/package.json +10 -12
- package/dist/formatter/debug.d.ts +0 -6
- package/dist/formatter/debug.js +0 -18
- package/dist/output/color-name/color-name.d.ts +0 -11
- package/dist/output/color-name/color-name.js +0 -27
- package/dist/output/format-body/format-body.d.ts +0 -1
- package/dist/output/format-body/format-body.js +0 -23
- package/dist/output/format-time/format-time.d.ts +0 -5
- package/dist/output/format-time/format-time.js +0 -21
- package/dist/output/stringify-level/stringify-level.d.ts +0 -1
- package/dist/output/stringify-level/stringify-level.js +0 -8
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ master, main ]
|
|
6
|
+
|
|
7
|
+
env:
|
|
8
|
+
NPM_TOKEN: ${{ secrets.SEMANTIC_RELEASE_NPM_TOKEN }}
|
|
9
|
+
GH_TOKEN: ${{ secrets.SEMANTIC_RELEASE_GH_TOKEN }}
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
test:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v3
|
|
17
|
+
- name: Node version
|
|
18
|
+
id: engines
|
|
19
|
+
run: echo "##[set-output name=NODE_VERSION;]$(cat .nvmrc)"
|
|
20
|
+
- name: Use Node.js ${{ steps.engines.outputs.NODE_VERSION }}
|
|
21
|
+
uses: actions/setup-node@v3
|
|
22
|
+
with:
|
|
23
|
+
node-version: ${{ steps.engines.outputs.NODE_VERSION }}
|
|
24
|
+
- name: Install
|
|
25
|
+
run: npm install
|
|
26
|
+
- name: Lint
|
|
27
|
+
run: npm run lint
|
|
28
|
+
- name: Test
|
|
29
|
+
run: npm run test
|
|
30
|
+
- name: Build
|
|
31
|
+
run: npm run build
|
|
32
|
+
- name: Release
|
|
33
|
+
run: npm run semantic-release
|
package/dist/config.d.ts
CHANGED
package/dist/config.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.config = void 0;
|
|
7
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
8
4
|
const levels = {
|
|
9
5
|
trace: {
|
|
10
6
|
number: 10,
|
|
@@ -20,20 +16,16 @@ const levels = {
|
|
|
20
16
|
},
|
|
21
17
|
warn: {
|
|
22
18
|
number: 40,
|
|
23
|
-
name:
|
|
19
|
+
name: 'WARN'
|
|
24
20
|
},
|
|
25
21
|
error: {
|
|
26
22
|
number: 50,
|
|
27
|
-
name:
|
|
23
|
+
name: 'ERROR'
|
|
28
24
|
},
|
|
29
25
|
fatal: {
|
|
30
26
|
number: 60,
|
|
31
|
-
name:
|
|
32
|
-
}
|
|
27
|
+
name: 'FATAL'
|
|
28
|
+
}
|
|
33
29
|
};
|
|
34
30
|
const availableLevels = Object.keys(levels);
|
|
35
|
-
|
|
36
|
-
availableLevels.forEach((levelName) => {
|
|
37
|
-
coloredNames[levels[levelName].number] = levels[levelName].name;
|
|
38
|
-
});
|
|
39
|
-
exports.config = { levels, availableLevels, coloredNames };
|
|
31
|
+
exports.config = { levels, availableLevels };
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { jsonFormatter } from './json';
|
|
2
2
|
import { logentriesFormatter } from './logentries';
|
|
3
|
-
import { debugFormatter } from './debug';
|
|
4
3
|
export declare const formatter: {
|
|
5
4
|
json: typeof jsonFormatter;
|
|
6
|
-
debug: typeof debugFormatter;
|
|
7
5
|
logentries: typeof logentriesFormatter;
|
|
8
6
|
};
|
package/dist/formatter/index.js
CHANGED
|
@@ -3,9 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.formatter = void 0;
|
|
4
4
|
const json_1 = require("./json");
|
|
5
5
|
const logentries_1 = require("./logentries");
|
|
6
|
-
const debug_1 = require("./debug");
|
|
7
6
|
exports.formatter = {
|
|
8
7
|
json: json_1.jsonFormatter,
|
|
9
|
-
debug: debug_1.debugFormatter,
|
|
10
8
|
logentries: logentries_1.logentriesFormatter
|
|
11
9
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,6 @@ export declare namespace createLogger {
|
|
|
7
7
|
var configure: (options: LoggerConfig) => void;
|
|
8
8
|
var formatter: {
|
|
9
9
|
json: typeof import("./formatter/json").jsonFormatter;
|
|
10
|
-
debug: typeof import("./formatter/debug").debugFormatter;
|
|
11
10
|
logentries: typeof import("./formatter/logentries").logentriesFormatter;
|
|
12
11
|
};
|
|
13
12
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@emartech/json-logger",
|
|
3
|
-
"version": "6.0.1",
|
|
4
3
|
"description": "Tiny and fast json logger with namespace support",
|
|
5
4
|
"main": "dist/index.js",
|
|
6
5
|
"scripts": {
|
|
@@ -28,26 +27,24 @@
|
|
|
28
27
|
"debug",
|
|
29
28
|
"json"
|
|
30
29
|
],
|
|
31
|
-
"dependencies": {
|
|
32
|
-
"chalk": "4.1.2"
|
|
33
|
-
},
|
|
30
|
+
"dependencies": {},
|
|
34
31
|
"devDependencies": {
|
|
35
32
|
"@emartech/cls-adapter": "1.3.0",
|
|
36
|
-
"@types/node": "18.7.
|
|
37
|
-
"@typescript-eslint/parser": "5.
|
|
33
|
+
"@types/node": "18.7.14",
|
|
34
|
+
"@typescript-eslint/parser": "5.36.1",
|
|
38
35
|
"chai": "4.3.6",
|
|
39
|
-
"eslint": "
|
|
36
|
+
"eslint": "8.23.0",
|
|
40
37
|
"eslint-config-emarsys": "5.1.0",
|
|
41
|
-
"eslint-plugin-no-only-tests": "
|
|
42
|
-
"eslint-plugin-security": "1.
|
|
38
|
+
"eslint-plugin-no-only-tests": "3.0.0",
|
|
39
|
+
"eslint-plugin-security": "1.5.0",
|
|
43
40
|
"express": "4.18.1",
|
|
44
41
|
"koa": "2.13.4",
|
|
45
42
|
"mocha": "10.0.0",
|
|
46
|
-
"semantic-release": "
|
|
43
|
+
"semantic-release": "19.0.5",
|
|
47
44
|
"sinon": "14.0.0",
|
|
48
45
|
"sinon-chai": "3.7.0",
|
|
49
46
|
"ts-node": "10.9.1",
|
|
50
|
-
"typescript": "4.
|
|
47
|
+
"typescript": "4.8.2"
|
|
51
48
|
},
|
|
52
49
|
"repository": {
|
|
53
50
|
"type": "git",
|
|
@@ -56,5 +53,6 @@
|
|
|
56
53
|
"bugs": {
|
|
57
54
|
"url": "https://github.com/emartech/json-logger-js/issues"
|
|
58
55
|
},
|
|
59
|
-
"homepage": "https://github.com/emartech/json-logger-js#readme"
|
|
56
|
+
"homepage": "https://github.com/emartech/json-logger-js#readme",
|
|
57
|
+
"version": "7.0.2"
|
|
60
58
|
}
|
package/dist/formatter/debug.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.debugFormatter = void 0;
|
|
4
|
-
const color_name_1 = require("../output/color-name/color-name");
|
|
5
|
-
const stringify_level_1 = require("../output/stringify-level/stringify-level");
|
|
6
|
-
const format_time_1 = require("../output/format-time/format-time");
|
|
7
|
-
const format_body_1 = require("../output/format-body/format-body");
|
|
8
|
-
const formatTime = new format_time_1.FormatTime();
|
|
9
|
-
function debugFormatter(log) {
|
|
10
|
-
return [
|
|
11
|
-
color_name_1.ColorName.addColor(log.name),
|
|
12
|
-
(0, stringify_level_1.stringifyLevel)(log.level),
|
|
13
|
-
formatTime.elapsedTime(),
|
|
14
|
-
(0, format_body_1.formatBody)(log)
|
|
15
|
-
].join(' ');
|
|
16
|
-
}
|
|
17
|
-
exports.debugFormatter = debugFormatter;
|
|
18
|
-
;
|
|
@@ -1,27 +0,0 @@
|
|
|
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
|
-
exports.ColorName = void 0;
|
|
7
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
-
const colors = ['cyan', 'magenta', 'grey', 'blue', 'green', 'yellow', 'white', 'red'];
|
|
9
|
-
class ColorName {
|
|
10
|
-
static addColor(name) {
|
|
11
|
-
if (!this.names[name]) {
|
|
12
|
-
this.names[name] = { color: this.counter % colors.length };
|
|
13
|
-
this.counter++;
|
|
14
|
-
}
|
|
15
|
-
const color = colors[this.names[name].color];
|
|
16
|
-
// @ts-ignore
|
|
17
|
-
return chalk_1.default[color](name);
|
|
18
|
-
}
|
|
19
|
-
static reset() {
|
|
20
|
-
this.counter = 0;
|
|
21
|
-
this.names = {};
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
exports.ColorName = ColorName;
|
|
25
|
-
ColorName.counter = 0;
|
|
26
|
-
ColorName.colors = colors;
|
|
27
|
-
ColorName.names = {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function formatBody(logBody: any): string;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.formatBody = void 0;
|
|
4
|
-
function formatBody(logBody) {
|
|
5
|
-
const log = Object.assign({}, logBody);
|
|
6
|
-
delete log.name;
|
|
7
|
-
delete log.level;
|
|
8
|
-
delete log.v;
|
|
9
|
-
delete log.pid;
|
|
10
|
-
delete log.hostname;
|
|
11
|
-
delete log.time;
|
|
12
|
-
if (!log.msg) {
|
|
13
|
-
delete log.msg;
|
|
14
|
-
}
|
|
15
|
-
const keys = Object.keys(log);
|
|
16
|
-
return keys
|
|
17
|
-
.sort()
|
|
18
|
-
.map(function (key) {
|
|
19
|
-
return key + '=' + JSON.stringify(log[key]);
|
|
20
|
-
})
|
|
21
|
-
.join(' ');
|
|
22
|
-
}
|
|
23
|
-
exports.formatBody = formatBody;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FormatTime = void 0;
|
|
4
|
-
class FormatTime {
|
|
5
|
-
constructor() {
|
|
6
|
-
this.lastLog = 0;
|
|
7
|
-
}
|
|
8
|
-
elapsedTime() {
|
|
9
|
-
const current = this.getCurrentTime();
|
|
10
|
-
let elapsed = 0;
|
|
11
|
-
if (this.lastLog) {
|
|
12
|
-
elapsed = current - this.lastLog;
|
|
13
|
-
}
|
|
14
|
-
this.lastLog = current;
|
|
15
|
-
return '+' + elapsed + 'ms';
|
|
16
|
-
}
|
|
17
|
-
getCurrentTime() {
|
|
18
|
-
return new Date().getTime();
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
exports.FormatTime = FormatTime;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function stringifyLevel(level: string): string;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.stringifyLevel = void 0;
|
|
4
|
-
const config_1 = require("../../config");
|
|
5
|
-
function stringifyLevel(level) {
|
|
6
|
-
return config_1.config.coloredNames[level];
|
|
7
|
-
}
|
|
8
|
-
exports.stringifyLevel = stringifyLevel;
|