json-log-line 0.0.2 → 1.0.0
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/README.md +28 -0
- package/package.json +29 -30
- package/dist/src/index.d.ts +0 -19
- package/dist/src/index.js +0 -102
- package/dist/src/index.js.map +0 -1
- package/dist/src/utils/is-empty.d.ts +0 -2
- package/dist/src/utils/is-empty.js +0 -9
- package/dist/src/utils/is-empty.js.map +0 -1
- package/dist/src/utils/is-object.d.ts +0 -2
- package/dist/src/utils/is-object.js +0 -6
- package/dist/src/utils/is-object.js.map +0 -1
- package/dist/test/create-log-line.d.ts +0 -1
- package/dist/test/create-log-line.js +0 -63
- package/dist/test/create-log-line.js.map +0 -1
package/README.md
CHANGED
|
@@ -105,6 +105,34 @@ Format is an object the represents how you want to parse the log object. It will
|
|
|
105
105
|
|
|
106
106
|
A special key that contains the rest of the log object fields which were both included and not formatted by a format function.
|
|
107
107
|
|
|
108
|
+
#### Multi keys
|
|
109
|
+
|
|
110
|
+
You can map a single formatter to multiple keys by separating them with a pipe (`|`). Each key is resolved independently (dot notation is supported) and rendered in order. Every matched value is passed through the same formatter, and each consumed key is removed from the remaining `extraFields` payload.
|
|
111
|
+
|
|
112
|
+
```javascript
|
|
113
|
+
const lineFormatter = logLineFactory({
|
|
114
|
+
format: {
|
|
115
|
+
// Applies to both top-level keys
|
|
116
|
+
'foo|baz': (value) => `!${value}`,
|
|
117
|
+
// Works with nested keys, too
|
|
118
|
+
'nested.a|other.a': (value) => `:${value}:`,
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
console.log(
|
|
123
|
+
lineFormatter(
|
|
124
|
+
JSON.stringify({
|
|
125
|
+
foo: 'bar',
|
|
126
|
+
baz: 'buz',
|
|
127
|
+
nested: {a: 'x', b: 'y'},
|
|
128
|
+
other: {a: 'z'},
|
|
129
|
+
}),
|
|
130
|
+
),
|
|
131
|
+
);
|
|
132
|
+
// => !bar !buz :x: :z:
|
|
133
|
+
// {"nested":{"b":"y"},"other":{}}
|
|
134
|
+
```
|
|
135
|
+
|
|
108
136
|
### include
|
|
109
137
|
|
|
110
138
|
`string[]`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "json-log-line",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "A utility for building awesome log lines from JSON",
|
|
5
5
|
"homepage": "https://github.com/spence-s/json-log-line",
|
|
6
6
|
"bugs": {
|
|
@@ -32,18 +32,12 @@
|
|
|
32
32
|
],
|
|
33
33
|
"scripts": {
|
|
34
34
|
"build": "npm run clean && tsc --project tsconfig.build.json",
|
|
35
|
-
"build:test": "npm run clean && tsc --project tsconfig.json",
|
|
36
|
-
"build:watch": "npm run clean && tsc --project tsconfig.json --watch",
|
|
37
35
|
"check": "tsc --project ./tsconfig.json",
|
|
38
36
|
"clean": "rimraf dist",
|
|
39
|
-
"
|
|
40
|
-
"dev:watch": "NODE_NO_WARNINGS=1 node --watch --loader ts-node/esm/transpile-only ./src/index.ts",
|
|
41
|
-
"lint": "xo",
|
|
42
|
-
"lint:fix": "xo --fix",
|
|
37
|
+
"lint": "npm run check && xo",
|
|
43
38
|
"prepare": "husky",
|
|
44
39
|
"release": "np",
|
|
45
|
-
"test": "
|
|
46
|
-
"test:watch": "ava --watch",
|
|
40
|
+
"test": "c8 ava",
|
|
47
41
|
"update": "ncu -i"
|
|
48
42
|
},
|
|
49
43
|
"prettier": {
|
|
@@ -52,40 +46,45 @@
|
|
|
52
46
|
]
|
|
53
47
|
},
|
|
54
48
|
"ava": {
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"!dist/test/fixtures/**",
|
|
58
|
-
"!dist/test/helpers/**"
|
|
49
|
+
"extensions": [
|
|
50
|
+
"ts"
|
|
59
51
|
],
|
|
60
|
-
"
|
|
61
|
-
"
|
|
52
|
+
"files": [
|
|
53
|
+
"test/**",
|
|
54
|
+
"!test/fixtures/**",
|
|
55
|
+
"!test/helpers/**"
|
|
62
56
|
],
|
|
63
57
|
"verbose": true
|
|
64
58
|
},
|
|
65
59
|
"dependencies": {
|
|
60
|
+
"@fastify/deepmerge": "^3.1.0",
|
|
66
61
|
"fast-json-parse": "^1.0.3",
|
|
67
|
-
"get-value": "^
|
|
62
|
+
"get-value": "^4.0.1",
|
|
68
63
|
"set-value": "^4.1.0",
|
|
69
64
|
"unset-value": "^2.0.1"
|
|
70
65
|
},
|
|
71
66
|
"devDependencies": {
|
|
72
|
-
"@commitlint/cli": "^
|
|
73
|
-
"@commitlint/config-conventional": "^
|
|
67
|
+
"@commitlint/cli": "^20.2.0",
|
|
68
|
+
"@commitlint/config-conventional": "^20.2.0",
|
|
74
69
|
"@types/get-value": "^3.0.5",
|
|
75
|
-
"@types/node": "^
|
|
70
|
+
"@types/node": "^25.0.3",
|
|
76
71
|
"@types/set-value": "^4.0.3",
|
|
77
|
-
"ava": "^6.1
|
|
78
|
-
"c8": "^10.1.
|
|
79
|
-
"husky": "^9.1.
|
|
80
|
-
"lint-staged": "^
|
|
81
|
-
"np": "^10.0
|
|
72
|
+
"ava": "^6.4.1",
|
|
73
|
+
"c8": "^10.1.3",
|
|
74
|
+
"husky": "^9.1.7",
|
|
75
|
+
"lint-staged": "^16.2.7",
|
|
76
|
+
"np": "^10.2.0",
|
|
82
77
|
"npm-check-updates": "latest",
|
|
83
|
-
"npm-package-json-lint": "^
|
|
84
|
-
"npm-package-json-lint-config-default": "^
|
|
85
|
-
"prettier": "^3.
|
|
86
|
-
"prettier-plugin-packagejson": "^2.5.
|
|
87
|
-
"rimraf": "^6.
|
|
78
|
+
"npm-package-json-lint": "^9.0.0",
|
|
79
|
+
"npm-package-json-lint-config-default": "^8.0.1",
|
|
80
|
+
"prettier": "^3.7.4",
|
|
81
|
+
"prettier-plugin-packagejson": "^2.5.20",
|
|
82
|
+
"rimraf": "^6.1.2",
|
|
88
83
|
"ts-node": "^10.9.2",
|
|
89
|
-
"
|
|
84
|
+
"typescript": "^5.9.3",
|
|
85
|
+
"xo": "^1.2.3"
|
|
86
|
+
},
|
|
87
|
+
"engines": {
|
|
88
|
+
"node": ">=22"
|
|
90
89
|
}
|
|
91
90
|
}
|
package/dist/src/index.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export type Options = {
|
|
2
|
-
exclude?: string | string[];
|
|
3
|
-
include?: string | string[];
|
|
4
|
-
format?: Record<string, (value: any, parsedLogObject?: any, ...arguments_: any[]) => string>;
|
|
5
|
-
logLineKeys?: string | string[];
|
|
6
|
-
};
|
|
7
|
-
export declare function logLineFactory({
|
|
8
|
-
/**
|
|
9
|
-
* include and exclude both take keys with dot notation
|
|
10
|
-
*/
|
|
11
|
-
exclude,
|
|
12
|
-
/**
|
|
13
|
-
* include always overrides exclude
|
|
14
|
-
*/
|
|
15
|
-
include,
|
|
16
|
-
/**
|
|
17
|
-
* Format functions for any given key, keys of the object are automatically included and cannot be excluded
|
|
18
|
-
*/
|
|
19
|
-
format, }?: Options): (inputData: string | Record<string, unknown>) => string;
|
package/dist/src/index.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import jsonParse from 'fast-json-parse';
|
|
2
|
-
import unset from 'unset-value';
|
|
3
|
-
import get from 'get-value';
|
|
4
|
-
import set from 'set-value';
|
|
5
|
-
import isObject from './utils/is-object.js';
|
|
6
|
-
import isEmpty from './utils/is-empty.js';
|
|
7
|
-
const nl = '\n';
|
|
8
|
-
export function logLineFactory({
|
|
9
|
-
/**
|
|
10
|
-
* include and exclude both take keys with dot notation
|
|
11
|
-
*/
|
|
12
|
-
exclude = [],
|
|
13
|
-
/**
|
|
14
|
-
* include always overrides exclude
|
|
15
|
-
*/
|
|
16
|
-
include = [],
|
|
17
|
-
/**
|
|
18
|
-
* Format functions for any given key, keys of the object are automatically included and cannot be excluded
|
|
19
|
-
*/
|
|
20
|
-
format = {}, } = {}) {
|
|
21
|
-
const logLineKeys = Object.keys(format);
|
|
22
|
-
format.extraFields ||= (object) => JSON.stringify(object) + nl;
|
|
23
|
-
/**
|
|
24
|
-
* @param inputData - The input data to be formatted can be a JSON stringified object or a plain object
|
|
25
|
-
*/
|
|
26
|
-
return function (inputData) {
|
|
27
|
-
try {
|
|
28
|
-
let object = {};
|
|
29
|
-
if (typeof inputData === 'string') {
|
|
30
|
-
const parsedData = jsonParse(inputData);
|
|
31
|
-
if (!parsedData.value || parsedData.err) {
|
|
32
|
-
return inputData + nl;
|
|
33
|
-
}
|
|
34
|
-
object = parsedData.value;
|
|
35
|
-
}
|
|
36
|
-
else if (isObject(inputData)) {
|
|
37
|
-
object = inputData;
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
return nl;
|
|
41
|
-
}
|
|
42
|
-
// cache the whitelist
|
|
43
|
-
const whiteListObject = {};
|
|
44
|
-
for (const key of [...logLineKeys, ...include]) {
|
|
45
|
-
const value = get(object, key);
|
|
46
|
-
if (value) {
|
|
47
|
-
set(whiteListObject, key, value);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
// remove the blacklist
|
|
51
|
-
for (const key of exclude) {
|
|
52
|
-
unset(object, key);
|
|
53
|
-
}
|
|
54
|
-
// add back in the whitelist
|
|
55
|
-
object = {
|
|
56
|
-
...object,
|
|
57
|
-
...whiteListObject,
|
|
58
|
-
};
|
|
59
|
-
const output = [];
|
|
60
|
-
for (const key of logLineKeys) {
|
|
61
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
62
|
-
const value = get(object, key);
|
|
63
|
-
if (!value) {
|
|
64
|
-
continue;
|
|
65
|
-
}
|
|
66
|
-
const formatter = format[key];
|
|
67
|
-
if (formatter) {
|
|
68
|
-
output.push(formatter(value, object));
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
// remove the properties that were used to create the log-line
|
|
72
|
-
for (const key of logLineKeys) {
|
|
73
|
-
unset(object, key);
|
|
74
|
-
}
|
|
75
|
-
// remove empty blacklist that may have had whitelisted properties
|
|
76
|
-
for (const key of exclude) {
|
|
77
|
-
if (isEmpty(get(object, key))) {
|
|
78
|
-
unset(object, key);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
let outputString = output.filter(Boolean).join(' ');
|
|
82
|
-
// after processing the rest of the object contains
|
|
83
|
-
// extra fields that were not in the logLine nor in the log line nor blacklisted
|
|
84
|
-
// so these are the ones we want to prettify and highlight
|
|
85
|
-
if (isObject(object) && !isEmpty(object) && format.extraFields) {
|
|
86
|
-
outputString = outputString.concat(format.extraFields(object));
|
|
87
|
-
}
|
|
88
|
-
if (!outputString.endsWith(nl)) {
|
|
89
|
-
outputString += nl;
|
|
90
|
-
}
|
|
91
|
-
if (outputString === nl) {
|
|
92
|
-
return JSON.stringify(object) + nl;
|
|
93
|
-
}
|
|
94
|
-
return outputString;
|
|
95
|
-
}
|
|
96
|
-
catch (error) {
|
|
97
|
-
console.log(error);
|
|
98
|
-
return '';
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
//# sourceMappingURL=index.js.map
|
package/dist/src/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,MAAM,aAAa,CAAC;AAChC,OAAO,GAAG,MAAM,WAAW,CAAC;AAC5B,OAAO,GAAG,MAAM,WAAW,CAAC;AAC5B,OAAO,QAAQ,MAAM,sBAAsB,CAAC;AAC5C,OAAO,OAAO,MAAM,qBAAqB,CAAC;AAc1C,MAAM,EAAE,GAAG,IAAI,CAAC;AAEhB,MAAM,UAAU,cAAc,CAAC;AAC7B;;GAEG;AACH,OAAO,GAAG,EAAE;AACZ;;GAEG;AACH,OAAO,GAAG,EAAE;AACZ;;GAEG;AACH,MAAM,GAAG,EAAE,MACA,EAAE;IACb,MAAM,W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K,EAAE,EAAE,CAAC;gBACxB,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;YACrC,CAAC;YAED,OAAO,YAAY,CAAC;QACtB,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YACnB,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-empty.js","sourceRoot":"","sources":["../../../src/utils/is-empty.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAEtC,SAAS,OAAO,CAAC,MAAe;IAC9B,OAAO,OAAO,CACZ,QAAQ,CAAC,MAAM,CAAC;QACd,CAAC,MAAM,KAAK,SAAS;YACnB,MAAM,KAAK,IAAI;YACf,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,CACtC,CAAC;AACJ,CAAC;AAED,eAAe,OAAO,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-object.js","sourceRoot":"","sources":["../../../src/utils/is-object.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,CACZ,KAAK,IAAI,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,iBAAiB,CACtE,CAAC;AACJ,CAAC;AAED,eAAe,QAAQ,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import test from 'ava';
|
|
2
|
-
import { logLineFactory } from '../src/index.js';
|
|
3
|
-
test('named export is a function', (t) => {
|
|
4
|
-
t.is(typeof logLineFactory, 'function');
|
|
5
|
-
});
|
|
6
|
-
test('returns the original JSON stringified string if no formatters are provided', (t) => {
|
|
7
|
-
const logLine = logLineFactory();
|
|
8
|
-
const input = JSON.stringify({ foo: 'bar' });
|
|
9
|
-
const result = logLine(input);
|
|
10
|
-
t.is(result, input + '\n');
|
|
11
|
-
});
|
|
12
|
-
test('returns the JSON stringified object if an object is the input', (t) => {
|
|
13
|
-
const logLine = logLineFactory();
|
|
14
|
-
const input = { foo: 'bar' };
|
|
15
|
-
const stringified = JSON.stringify(input);
|
|
16
|
-
t.is(logLine(input), stringified + '\n');
|
|
17
|
-
});
|
|
18
|
-
test('creates a simple log line', (t) => {
|
|
19
|
-
const input = JSON.stringify({ foo: 'bar' });
|
|
20
|
-
const format = {
|
|
21
|
-
foo: (value) => value,
|
|
22
|
-
};
|
|
23
|
-
const logLine = logLineFactory({ format });
|
|
24
|
-
t.is(logLine(input), 'bar\n');
|
|
25
|
-
});
|
|
26
|
-
test('creates a simple log line with default extra fields', (t) => {
|
|
27
|
-
const input = JSON.stringify({ foo: 'bar', extra: 'baz' });
|
|
28
|
-
const format = {
|
|
29
|
-
foo: (value) => value + '\n',
|
|
30
|
-
};
|
|
31
|
-
const logLine = logLineFactory({ format });
|
|
32
|
-
t.is(logLine(input), 'bar\n{"extra":"baz"}\n');
|
|
33
|
-
});
|
|
34
|
-
test('creates a simple log line with formatted extra fields', (t) => {
|
|
35
|
-
const input = JSON.stringify({ foo: 'bar', extra: 'baz' });
|
|
36
|
-
const format = {
|
|
37
|
-
foo: (value) => value + '\n',
|
|
38
|
-
extraFields: (value) => JSON.stringify(value, null, 2),
|
|
39
|
-
};
|
|
40
|
-
const logLine = logLineFactory({ format });
|
|
41
|
-
t.is(logLine(input), 'bar\n' + JSON.stringify({ extra: 'baz' }, null, 2) + '\n');
|
|
42
|
-
});
|
|
43
|
-
test('nested fields can be added to log line and removed from extra fields', (t) => {
|
|
44
|
-
const input = JSON.stringify({ foo: { bar: 'baz' } });
|
|
45
|
-
const format = {
|
|
46
|
-
'foo.bar': (value) => value + '\n',
|
|
47
|
-
};
|
|
48
|
-
const logLine = logLineFactory({ format });
|
|
49
|
-
t.is(logLine(input), 'baz\n{"foo":{}}\n');
|
|
50
|
-
});
|
|
51
|
-
test('nested respect exlude and include', (t) => {
|
|
52
|
-
const input = JSON.stringify({ foo: { bar: 'baz', biz: 'buz', no: 'output' } });
|
|
53
|
-
const format = {
|
|
54
|
-
'foo.bar': (value) => value + '\n',
|
|
55
|
-
};
|
|
56
|
-
const logLine = logLineFactory({
|
|
57
|
-
format,
|
|
58
|
-
exclude: ['foo'],
|
|
59
|
-
include: ['foo.biz'],
|
|
60
|
-
});
|
|
61
|
-
t.is(logLine(input), 'baz\n{"foo":{"biz":"buz"}}\n');
|
|
62
|
-
});
|
|
63
|
-
//# sourceMappingURL=create-log-line.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-log-line.js","sourceRoot":"","sources":["../../test/create-log-line.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,KAAK,CAAC;AACvB,OAAO,EAAC,cAAc,EAAC,MAAM,iBAAiB,CAAC;AAE/C,IAAI,CAAC,4BAA4B,EAAE,CAAC,CAAC,EAAE,EAAE;IACvC,CAAC,CAAC,EAAE,CAAC,OAAO,cAAc,EAAE,UAAU,CAAC,CAAC;AAC1C,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,4EAA4E,EAAE,CAAC,CAAC,EAAE,EAAE;IACvF,MAAM,OAAO,GAAG,cAAc,EAAE,CAAC;IACjC,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,EAAC,GAAG,EAAE,KAAK,EAAC,CAAC,CAAC;IAC3C,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,GAAG,IAAI,CAAC,CAAC;AAC7B,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,+DAA+D,EAAE,CAAC,CAAC,EAAE,EAAE;IAC1E,MAAM,OAAO,GAA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