@apolitical/logger 2.1.2 → 3.0.0-bht.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/package.json +3 -5
- package/src/config.js +1 -5
- package/src/services/logger.service.js +9 -15
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apolitical/logger",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-bht.0",
|
|
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",
|
|
@@ -15,8 +15,7 @@
|
|
|
15
15
|
"lint": "eslint --ext .js ./src",
|
|
16
16
|
"format": "prettier --write 'src/**/*.+(js|json)'",
|
|
17
17
|
"lint-format": "lint-staged",
|
|
18
|
-
"audit": "audit-ci -h"
|
|
19
|
-
"prepare": "cd ../../../../ && husky install backend/modules/v1/apolitical-logger/.husky"
|
|
18
|
+
"audit": "audit-ci -h"
|
|
20
19
|
},
|
|
21
20
|
"keywords": [
|
|
22
21
|
"Backend",
|
|
@@ -31,13 +30,12 @@
|
|
|
31
30
|
"devDependencies": {
|
|
32
31
|
"@apolitical/eslint-config": "2.1.0",
|
|
33
32
|
"audit-ci": "6.5.0",
|
|
34
|
-
"husky": "8.0.3",
|
|
35
33
|
"jest": "29.3.1",
|
|
36
34
|
"jest-junit": "15.0.0",
|
|
37
35
|
"lint-staged": "13.1.0"
|
|
38
36
|
},
|
|
39
37
|
"engines": {
|
|
40
|
-
"node": ">=
|
|
38
|
+
"node": ">=20.14.0"
|
|
41
39
|
},
|
|
42
40
|
"eslintConfig": {
|
|
43
41
|
"extends": "@apolitical/eslint-config/api.config"
|
package/src/config.js
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const {
|
|
3
|
+
const { NODE_ENV } = process.env;
|
|
4
4
|
|
|
5
5
|
module.exports = {
|
|
6
|
-
GOOGLE: {
|
|
7
|
-
CLOUD_FUNCTION: GOOGLE_CLOUD_FUNCTION,
|
|
8
|
-
CREDENTIALS: GOOGLE_APPLICATION_CREDENTIALS,
|
|
9
|
-
},
|
|
10
6
|
LOGGER: {
|
|
11
7
|
LOGGING_LEVELS: ['error', 'warn', 'info', 'debug'],
|
|
12
8
|
TRANSPORTS: {
|
|
@@ -5,8 +5,6 @@ module.exports =
|
|
|
5
5
|
({ labels = {}, logLevel = 'info' }) => {
|
|
6
6
|
const { LOGGING_LEVELS } = config.LOGGER;
|
|
7
7
|
const { ERROR_OPTIONS, COMBINED_OPTIONS } = config.LOGGER.TRANSPORTS.FILE;
|
|
8
|
-
const { CLOUD_FUNCTION, CREDENTIALS } = config.GOOGLE;
|
|
9
|
-
|
|
10
8
|
function loggingLevels() {
|
|
11
9
|
return LOGGING_LEVELS.reduce((acc, cv, idx) => {
|
|
12
10
|
acc[cv] = idx;
|
|
@@ -17,19 +15,15 @@ module.exports =
|
|
|
17
15
|
function loggerTransports() {
|
|
18
16
|
const transports = [];
|
|
19
17
|
if (config.NODE_ENV === 'production') {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
);
|
|
30
|
-
} else {
|
|
31
|
-
transports.push(new winston.transports.Console());
|
|
32
|
-
}
|
|
18
|
+
transports.push(
|
|
19
|
+
new winstonGoogle.LoggingWinston({
|
|
20
|
+
labels,
|
|
21
|
+
serviceContext: {
|
|
22
|
+
service: labels.name,
|
|
23
|
+
version: labels.version,
|
|
24
|
+
},
|
|
25
|
+
}),
|
|
26
|
+
);
|
|
33
27
|
} else {
|
|
34
28
|
transports.push(new winston.transports.Console());
|
|
35
29
|
transports.push(new winston.transports.File(ERROR_OPTIONS));
|