@naturalcycles/backend-lib 4.20.1 → 4.20.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/dist/sentry/sentry.shared.service.js +2 -2
- package/dist/server/appEngineLogMiddleware.js +2 -2
- package/dist/server/simpleRequestLoggerMiddleware.js +1 -1
- package/package.json +1 -1
- package/src/sentry/sentry.shared.service.ts +3 -3
- package/src/server/appEngineLogMiddleware.ts +3 -3
- package/src/server/simpleRequestLoggerMiddleware.ts +1 -1
|
@@ -90,7 +90,7 @@ class SentrySharedService {
|
|
|
90
90
|
// It will log additional "breadcrumb object" before the error
|
|
91
91
|
// It's a Breadcrumb, not a console.log, because console.log are NOT automatically attached as Breadcrumbs in cron-job environments (outside of Express)
|
|
92
92
|
this.sentry().addBreadcrumb({
|
|
93
|
-
message: (0, nodejs_lib_1.
|
|
93
|
+
message: (0, nodejs_lib_1._inspect)(err, INSPECT_OPT),
|
|
94
94
|
});
|
|
95
95
|
return this.sentry().captureException(err);
|
|
96
96
|
}
|
|
@@ -116,7 +116,7 @@ class SentrySharedService {
|
|
|
116
116
|
log: () => { },
|
|
117
117
|
warn: () => { },
|
|
118
118
|
error: (...args) => {
|
|
119
|
-
const message = args.map(arg => (0, nodejs_lib_1.
|
|
119
|
+
const message = args.map(arg => (0, nodejs_lib_1._inspect)(arg, INSPECT_OPT)).join(' ');
|
|
120
120
|
this.sentry().addBreadcrumb({
|
|
121
121
|
message,
|
|
122
122
|
});
|
|
@@ -44,7 +44,7 @@ function logToDev(requestId, args) {
|
|
|
44
44
|
// Run on local machine
|
|
45
45
|
console.log([
|
|
46
46
|
requestId ? [(0, nodejs_lib_1.dimGrey)(`[${requestId}]`)] : [],
|
|
47
|
-
...args.map(a => (0, nodejs_lib_1.
|
|
47
|
+
...args.map(a => (0, nodejs_lib_1._inspect)(a, { includeErrorStack: true, colors: true })),
|
|
48
48
|
].join(' '));
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
@@ -52,7 +52,7 @@ function logToDev(requestId, args) {
|
|
|
52
52
|
* This is to not confuse e.g Sentry when it picks up messages with colors
|
|
53
53
|
*/
|
|
54
54
|
function logToCI(args) {
|
|
55
|
-
console.log(args.map(a => (0, nodejs_lib_1.
|
|
55
|
+
console.log(args.map(a => (0, nodejs_lib_1._inspect)(a, { includeErrorStack: true, colors: false })).join(' '));
|
|
56
56
|
}
|
|
57
57
|
function appEngineLogMiddleware() {
|
|
58
58
|
if (!isGAE || !GOOGLE_CLOUD_PROJECT) {
|
|
@@ -27,7 +27,7 @@ function simpleRequestLoggerMiddleware(_cfg = {}) {
|
|
|
27
27
|
(0, request_log_util_1.logRequest)(req, res.statusCode, (0, nodejs_lib_1.dimGrey)((0, js_lib_1._since)(started)));
|
|
28
28
|
// Avoid logging twice. It was previously logged by genericErrorHandler
|
|
29
29
|
// if (res.__err) {
|
|
30
|
-
// logRequest(req, res.statusCode, dimGrey(_since(started)),
|
|
30
|
+
// logRequest(req, res.statusCode, dimGrey(_since(started)), _inspect(res.__err))
|
|
31
31
|
// } else {
|
|
32
32
|
// logRequest(req, res.statusCode, dimGrey(_since(started)))
|
|
33
33
|
// }
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
CommonLogger,
|
|
6
6
|
CommonLogLevel,
|
|
7
7
|
} from '@naturalcycles/js-lib'
|
|
8
|
-
import {
|
|
8
|
+
import { _inspect, InspectAnyOptions } from '@naturalcycles/nodejs-lib'
|
|
9
9
|
// eslint-disable-next-line import/no-duplicates
|
|
10
10
|
import type { Breadcrumb, NodeOptions, SeverityLevel } from '@sentry/node'
|
|
11
11
|
// eslint-disable-next-line import/no-duplicates
|
|
@@ -115,7 +115,7 @@ export class SentrySharedService {
|
|
|
115
115
|
// It will log additional "breadcrumb object" before the error
|
|
116
116
|
// It's a Breadcrumb, not a console.log, because console.log are NOT automatically attached as Breadcrumbs in cron-job environments (outside of Express)
|
|
117
117
|
this.sentry().addBreadcrumb({
|
|
118
|
-
message:
|
|
118
|
+
message: _inspect(err, INSPECT_OPT),
|
|
119
119
|
})
|
|
120
120
|
|
|
121
121
|
return this.sentry().captureException(err)
|
|
@@ -145,7 +145,7 @@ export class SentrySharedService {
|
|
|
145
145
|
log: () => {}, // noop
|
|
146
146
|
warn: () => {}, // noop
|
|
147
147
|
error: (...args) => {
|
|
148
|
-
const message = args.map(arg =>
|
|
148
|
+
const message = args.map(arg => _inspect(arg, INSPECT_OPT)).join(' ')
|
|
149
149
|
|
|
150
150
|
this.sentry().addBreadcrumb({
|
|
151
151
|
message,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { inspect } from 'node:util'
|
|
2
2
|
import { AnyObject, CommonLogger } from '@naturalcycles/js-lib'
|
|
3
|
-
import { dimGrey,
|
|
3
|
+
import { dimGrey, _inspect } from '@naturalcycles/nodejs-lib'
|
|
4
4
|
import { BackendRequestHandler } from './server.model'
|
|
5
5
|
|
|
6
6
|
const { GOOGLE_CLOUD_PROJECT, GAE_INSTANCE } = process.env
|
|
@@ -53,7 +53,7 @@ function logToDev(requestId: string | null, args: any[]): void {
|
|
|
53
53
|
console.log(
|
|
54
54
|
[
|
|
55
55
|
requestId ? [dimGrey(`[${requestId}]`)] : [],
|
|
56
|
-
...args.map(a =>
|
|
56
|
+
...args.map(a => _inspect(a, { includeErrorStack: true, colors: true })),
|
|
57
57
|
].join(' '),
|
|
58
58
|
)
|
|
59
59
|
}
|
|
@@ -63,7 +63,7 @@ function logToDev(requestId: string | null, args: any[]): void {
|
|
|
63
63
|
* This is to not confuse e.g Sentry when it picks up messages with colors
|
|
64
64
|
*/
|
|
65
65
|
function logToCI(args: any[]): void {
|
|
66
|
-
console.log(args.map(a =>
|
|
66
|
+
console.log(args.map(a => _inspect(a, { includeErrorStack: true, colors: false })).join(' '))
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
export function appEngineLogMiddleware(): BackendRequestHandler {
|
|
@@ -44,7 +44,7 @@ export function simpleRequestLoggerMiddleware(
|
|
|
44
44
|
|
|
45
45
|
// Avoid logging twice. It was previously logged by genericErrorHandler
|
|
46
46
|
// if (res.__err) {
|
|
47
|
-
// logRequest(req, res.statusCode, dimGrey(_since(started)),
|
|
47
|
+
// logRequest(req, res.statusCode, dimGrey(_since(started)), _inspect(res.__err))
|
|
48
48
|
// } else {
|
|
49
49
|
// logRequest(req, res.statusCode, dimGrey(_since(started)))
|
|
50
50
|
// }
|