@apolitical/logger 2.0.0-beta.2 → 2.0.0-beta.6
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 +10 -0
- package/package.json +2 -2
- package/src/services/logger.service.js +4 -16
package/README.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
Node.js module to expose Apolitical's logger service
|
|
4
4
|
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
Requires the following to run:
|
|
8
|
+
|
|
9
|
+
- [node.js][node] 16.13.2+
|
|
10
|
+
- [yarn][yarn]
|
|
11
|
+
|
|
12
|
+
[node]: https://nodejs.org/en/download/
|
|
13
|
+
[yarn]: https://classic.yarnpkg.com/en/docs/install
|
|
14
|
+
|
|
5
15
|
## Installation
|
|
6
16
|
|
|
7
17
|
Install with `yarn`:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apolitical/logger",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.6",
|
|
4
4
|
"description": "Node.js module to expose Apolitical's logger service",
|
|
5
5
|
"author": "Apolitical Group Limited <engineering@apolitical.co>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"husky": "7.0.4",
|
|
35
35
|
"jest": "27.4.7",
|
|
36
36
|
"jest-junit": "13.0.0",
|
|
37
|
-
"lint-staged": "12.
|
|
37
|
+
"lint-staged": "12.2.0"
|
|
38
38
|
},
|
|
39
39
|
"engines": {
|
|
40
40
|
"node": ">=16.13.2"
|
|
@@ -51,30 +51,18 @@ module.exports =
|
|
|
51
51
|
return winston.format.combine(winston.format.colorize(), winston.format.simple());
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
function filterFunctionality(logger) {
|
|
55
|
-
return LOGGING_LEVELS.reduce(
|
|
56
|
-
(acc, cv) => {
|
|
57
|
-
acc[cv] = (message, extras = null) => {
|
|
58
|
-
if (extras) logger[cv](message, extras);
|
|
59
|
-
else logger[cv](message);
|
|
60
|
-
};
|
|
61
|
-
return acc;
|
|
62
|
-
},
|
|
63
|
-
{ labels: logger.labels, transports: logger.transports },
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
54
|
function createWrapper(logger) {
|
|
68
55
|
function where(filePath, method) {
|
|
69
56
|
const file = path.basename(filePath);
|
|
70
|
-
const childLogger = logger.child({
|
|
57
|
+
const childLogger = logger.child({
|
|
58
|
+
labels: Object.assign({}, allowedLabels(), { file, method }),
|
|
59
|
+
});
|
|
71
60
|
return createWrapper(childLogger);
|
|
72
61
|
}
|
|
73
62
|
function write(message) {
|
|
74
63
|
logger.info(message);
|
|
75
64
|
}
|
|
76
|
-
|
|
77
|
-
return Object.assign(instance, { where, stream: { write } });
|
|
65
|
+
return Object.assign(logger, { where, stream: { write } });
|
|
78
66
|
}
|
|
79
67
|
|
|
80
68
|
const loggerInstance = winston.createLogger({
|