@lucaapp/service-utils 5.35.0 → 5.37.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/dist/lib/logger/index.js +18 -2
- package/package.json +19 -7
package/dist/lib/logger/index.js
CHANGED
|
@@ -60,16 +60,28 @@ const ignore = (request) => {
|
|
|
60
60
|
false);
|
|
61
61
|
};
|
|
62
62
|
exports.ignore = ignore;
|
|
63
|
+
// Sentry is an optional peer dependency: services that do not report to
|
|
64
|
+
// Sentry do not install @sentry/node or pino-sentry-transport.
|
|
65
|
+
const isInstalled = (moduleName) => {
|
|
66
|
+
try {
|
|
67
|
+
require.resolve(moduleName);
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
63
74
|
class LoggerFactory {
|
|
64
75
|
static getLogger(logLevel, sentryOptions) {
|
|
65
76
|
const { sentryDsn, releaseVersion, minLevel } = sentryOptions ?? {};
|
|
77
|
+
const withSentry = !!sentryDsn && isInstalled('pino-sentry-transport');
|
|
66
78
|
const transports = [
|
|
67
79
|
{
|
|
68
80
|
target: 'pino/file',
|
|
69
81
|
options: { destination: 1 },
|
|
70
82
|
level: logLevel,
|
|
71
83
|
},
|
|
72
|
-
...(
|
|
84
|
+
...(withSentry
|
|
73
85
|
? [
|
|
74
86
|
{
|
|
75
87
|
target: 'pino-sentry-transport',
|
|
@@ -89,7 +101,7 @@ class LoggerFactory {
|
|
|
89
101
|
]
|
|
90
102
|
: []),
|
|
91
103
|
];
|
|
92
|
-
|
|
104
|
+
const logger = (0, pino_1.default)({
|
|
93
105
|
level: logLevel,
|
|
94
106
|
mixin: requestTracer_1.getRequestTracerMixin,
|
|
95
107
|
serializers: {
|
|
@@ -100,6 +112,10 @@ class LoggerFactory {
|
|
|
100
112
|
targets: transports,
|
|
101
113
|
},
|
|
102
114
|
});
|
|
115
|
+
if (sentryDsn && !withSentry) {
|
|
116
|
+
logger.warn('sentryDsn is set but pino-sentry-transport is not installed, Sentry reporting is off');
|
|
117
|
+
}
|
|
118
|
+
return logger;
|
|
103
119
|
}
|
|
104
120
|
static getHttpLogger(options) {
|
|
105
121
|
const { requestSerializer, responseSerializer, errorSerializer, defaultHttpLogLevel, customMessage, } = new HttpLoggerHelpers(options);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lucaapp/service-utils",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.37.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -23,7 +23,6 @@
|
|
|
23
23
|
"@aws-sdk/client-s3": "^3.1035.0",
|
|
24
24
|
"@aws-sdk/lib-storage": "^3.1035.0",
|
|
25
25
|
"@hapi/boom": "^10.0.1",
|
|
26
|
-
"@sentry/node": "^9.10.1",
|
|
27
26
|
"@tsconfig/node24": "24.0.0",
|
|
28
27
|
"@types/express": "4.17.23",
|
|
29
28
|
"@types/express-serve-static-core": "^4.17.43",
|
|
@@ -47,7 +46,6 @@
|
|
|
47
46
|
"moment-timezone": "^0.5.44",
|
|
48
47
|
"negotiator": "^0.6.4",
|
|
49
48
|
"pino-http": "9.0.0",
|
|
50
|
-
"pino-sentry-transport": "^1.5.1",
|
|
51
49
|
"prom-client": "14.1.0",
|
|
52
50
|
"response-time": "2.3.4",
|
|
53
51
|
"sequelize": "6.37.8",
|
|
@@ -61,6 +59,7 @@
|
|
|
61
59
|
"pg-boss": "12.14.0"
|
|
62
60
|
},
|
|
63
61
|
"devDependencies": {
|
|
62
|
+
"@sentry/node": "^9.10.1",
|
|
64
63
|
"@types/busboy": "^1.5.4",
|
|
65
64
|
"@types/lodash": "^4.14.187",
|
|
66
65
|
"@types/negotiator": "^0.6.4",
|
|
@@ -69,20 +68,33 @@
|
|
|
69
68
|
"@types/uuid": "^10.0.0",
|
|
70
69
|
"@typescript-eslint/eslint-plugin": "^7.15.0",
|
|
71
70
|
"@typescript-eslint/parser": "^7.15.0",
|
|
71
|
+
"@typescript/native": "npm:typescript@7.0.2",
|
|
72
72
|
"@vitest/coverage-v8": "4.1.1",
|
|
73
73
|
"conventional-changelog-conventionalcommits": "^8.0.0",
|
|
74
74
|
"eslint": "8.57.0",
|
|
75
75
|
"eslint-plugin-prettier": "4.2.1",
|
|
76
76
|
"eslint-plugin-vitest": "0.4.1",
|
|
77
|
-
"
|
|
77
|
+
"pino-sentry-transport": "^1.5.1",
|
|
78
78
|
"prettier": "2.7.1",
|
|
79
79
|
"semantic-release": "^25.0.3",
|
|
80
80
|
"semantic-release-monorepo": "8.0.2",
|
|
81
81
|
"supertest": "6.3.4",
|
|
82
|
-
"@typescript/native": "npm:typescript@7.0.2",
|
|
83
82
|
"typescript": "npm:@typescript/typescript6@6.0.2",
|
|
84
83
|
"vite-tsconfig-paths": "4.3.2",
|
|
85
|
-
"vitest": "4.1.1"
|
|
84
|
+
"vitest": "4.1.1",
|
|
85
|
+
"yarn-osv-audit": "0.1.8"
|
|
86
|
+
},
|
|
87
|
+
"peerDependencies": {
|
|
88
|
+
"@sentry/node": "^9.10.1",
|
|
89
|
+
"pino-sentry-transport": "^1.5.1"
|
|
90
|
+
},
|
|
91
|
+
"peerDependenciesMeta": {
|
|
92
|
+
"@sentry/node": {
|
|
93
|
+
"optional": true
|
|
94
|
+
},
|
|
95
|
+
"pino-sentry-transport": {
|
|
96
|
+
"optional": true
|
|
97
|
+
}
|
|
86
98
|
},
|
|
87
99
|
"resolutions": {
|
|
88
100
|
"tar": "7.5.21",
|
|
@@ -101,7 +113,7 @@
|
|
|
101
113
|
"follow-redirects": "^1.16.0",
|
|
102
114
|
"axios": "1.18.0",
|
|
103
115
|
"path-to-regexp": "0.1.13",
|
|
104
|
-
"ip-address": "10.
|
|
116
|
+
"ip-address": "10.5.1",
|
|
105
117
|
"fast-xml-builder": "^1.1.7",
|
|
106
118
|
"brace-expansion": "2.1.4",
|
|
107
119
|
"form-data": "4.0.6",
|