@ogcio/fastify-logging-wrapper 5.0.2 → 5.1.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/__tests__/fastify-logging-wrapper.errors.test.ts +106 -95
- package/__tests__/fastify-logging-wrapper.test.ts +102 -87
- package/__tests__/helpers/build-fastify.ts +10 -8
- package/__tests__/helpers/build-logger.ts +1 -1
- package/__tests__/helpers/fastify-test-helpers.ts +33 -11
- package/__tests__/logging-wrapper.test.ts +62 -53
- package/dist/fastify-logging-wrapper.d.ts +2 -2
- package/dist/fastify-logging-wrapper.d.ts.map +1 -1
- package/dist/fastify-logging-wrapper.js +1 -1
- package/dist/fastify-logging-wrapper.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/logging-wrapper-entities.d.ts +2 -3
- package/dist/logging-wrapper-entities.d.ts.map +1 -1
- package/dist/logging-wrapper-entities.js +1 -1
- package/dist/logging-wrapper-entities.js.map +1 -1
- package/dist/logging-wrapper.d.ts +4 -4
- package/dist/logging-wrapper.d.ts.map +1 -1
- package/dist/logging-wrapper.js +0 -1
- package/dist/logging-wrapper.js.map +1 -1
- package/package.json +3 -3
- package/src/fastify-logging-wrapper.ts +27 -11
- package/src/index.ts +4 -1
- package/src/logging-wrapper-entities.ts +5 -9
- package/src/logging-wrapper.ts +8 -8
- package/vitest.config.mts +20 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import assert from
|
|
1
|
+
import { httpErrors } from "@fastify/sensible";
|
|
2
|
+
import { assert, afterEach, describe, it } from "vitest";
|
|
3
3
|
import { LogErrorClasses } from "../src/logging-wrapper-entities.js";
|
|
4
4
|
import {
|
|
5
5
|
DEFAULT_METHOD,
|
|
@@ -11,117 +11,128 @@ import {
|
|
|
11
11
|
parseLogEntry,
|
|
12
12
|
runErrorTest,
|
|
13
13
|
} from "./helpers/fastify-test-helpers.js";
|
|
14
|
-
import { httpErrors } from '@fastify/sensible';
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
15
|
+
describe("Error data are correctly set", () => {
|
|
16
|
+
it("should pass", async () => {
|
|
17
|
+
const { server, loggingDestination } = initializeServer();
|
|
18
|
+
afterEach(() => server.close());
|
|
19
|
+
await runErrorTest({
|
|
20
|
+
server,
|
|
21
|
+
loggingDestination,
|
|
22
|
+
inputStatusCode: "500",
|
|
23
|
+
expectedStatusCode: 500,
|
|
24
|
+
errorMessage: "WHoooopS!",
|
|
25
|
+
expectedClass: LogErrorClasses.ServerError,
|
|
26
|
+
});
|
|
26
27
|
});
|
|
27
28
|
});
|
|
28
29
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
30
|
+
describe("Unknown Error route logs expected values", () => {
|
|
31
|
+
it("should pass", async () => {
|
|
32
|
+
const { server, loggingDestination } = initializeServer();
|
|
33
|
+
afterEach(() => server.close());
|
|
34
|
+
await runErrorTest({
|
|
35
|
+
server,
|
|
36
|
+
loggingDestination,
|
|
37
|
+
inputStatusCode: "399",
|
|
38
|
+
expectedStatusCode: 500,
|
|
39
|
+
errorMessage: "Unknown!",
|
|
40
|
+
expectedClass: LogErrorClasses.UnknownError,
|
|
41
|
+
});
|
|
39
42
|
});
|
|
40
43
|
});
|
|
41
44
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
describe("400 Error route logs expected values", () => {
|
|
46
|
+
it("should pass", async () => {
|
|
47
|
+
const { server, loggingDestination } = initializeServer();
|
|
48
|
+
afterEach(() => server.close());
|
|
49
|
+
await runErrorTest({
|
|
50
|
+
server,
|
|
51
|
+
loggingDestination,
|
|
52
|
+
inputStatusCode: "400",
|
|
53
|
+
expectedStatusCode: 400,
|
|
54
|
+
errorMessage: "Bad request!",
|
|
55
|
+
expectedClass: LogErrorClasses.RequestError,
|
|
56
|
+
});
|
|
52
57
|
});
|
|
53
58
|
});
|
|
54
59
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
describe("422 Validation Error route logs expected values", () => {
|
|
61
|
+
it("should pass", async () => {
|
|
62
|
+
const { server, loggingDestination } = initializeServer();
|
|
63
|
+
afterEach(() => server.close());
|
|
64
|
+
await runErrorTest({
|
|
65
|
+
server,
|
|
66
|
+
loggingDestination,
|
|
67
|
+
inputStatusCode: "422",
|
|
68
|
+
expectedStatusCode: 422,
|
|
69
|
+
errorMessage: "Bad request!",
|
|
70
|
+
expectedClass: LogErrorClasses.ValidationError,
|
|
71
|
+
});
|
|
65
72
|
});
|
|
66
73
|
});
|
|
67
74
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
describe("Error without status code logs expected values", () => {
|
|
76
|
+
it("should pass", async () => {
|
|
77
|
+
const { server, loggingDestination } = initializeServer();
|
|
78
|
+
afterEach(() => server.close());
|
|
79
|
+
await runErrorTest({
|
|
80
|
+
server,
|
|
81
|
+
loggingDestination,
|
|
82
|
+
inputStatusCode: undefined,
|
|
83
|
+
expectedStatusCode: 500,
|
|
84
|
+
errorMessage: "Unknown!",
|
|
85
|
+
expectedClass: LogErrorClasses.UnknownError,
|
|
86
|
+
expectedFastifyCode: "UNHANDLED_EXCEPTION",
|
|
87
|
+
});
|
|
79
88
|
});
|
|
80
89
|
});
|
|
81
90
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
91
|
+
describe("Life events error logs expected values", () => {
|
|
92
|
+
it("should pass", async () => {
|
|
93
|
+
const { server, loggingDestination } = initializeServer();
|
|
94
|
+
afterEach(() => server.close());
|
|
95
|
+
const response = await server.inject({
|
|
96
|
+
method: DEFAULT_METHOD,
|
|
97
|
+
url: "/life-events-error",
|
|
98
|
+
});
|
|
89
99
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
100
|
+
assert.ok(typeof response !== "undefined");
|
|
101
|
+
assert.equal(response.statusCode, 500);
|
|
102
|
+
const loggedRecords = loggingDestination.getLoggedRecords();
|
|
103
|
+
assert.equal(loggedRecords.length, 4);
|
|
104
|
+
const mockErrorInstance = httpErrors.createError("mock");
|
|
105
|
+
checkExpectedRequestEntry({
|
|
106
|
+
requestLogEntry: loggedRecords[0],
|
|
107
|
+
inputPath: "/life-events-error",
|
|
108
|
+
});
|
|
99
109
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
checkExpectedErrorEntry({
|
|
111
|
+
errorLogEntry: loggedRecords[1],
|
|
112
|
+
inputPath: "/life-events-error",
|
|
113
|
+
errorClass: LogErrorClasses.ServerError,
|
|
114
|
+
errorMessage: "mock",
|
|
115
|
+
errorCode: mockErrorInstance.name,
|
|
116
|
+
expectedLevelName: "ERROR",
|
|
117
|
+
});
|
|
118
|
+
const parsed = parseLogEntry(loggedRecords[1]);
|
|
119
|
+
assert.equal(parsed.error.process, "TESTING");
|
|
120
|
+
assert.equal(parsed.error.parent.message, "I am the parent");
|
|
121
|
+
assert.equal(parsed.error.parent.name, "Error");
|
|
122
|
+
assert.equal(typeof parsed.error.parent.stack, "string");
|
|
113
123
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
124
|
+
checkExpectedResponseEntry({
|
|
125
|
+
responseLogEntry: loggedRecords[2],
|
|
126
|
+
inputPath: "/life-events-error",
|
|
127
|
+
responseStatusCode: 500,
|
|
128
|
+
});
|
|
129
|
+
checkExpectedApiTrackEntry({
|
|
130
|
+
apiTrackLogEntry: loggedRecords[3],
|
|
131
|
+
inputPath: "/life-events-error",
|
|
132
|
+
responseStatusCode: 500,
|
|
133
|
+
errorClass: LogErrorClasses.ServerError,
|
|
134
|
+
errorMessage: "mock",
|
|
135
|
+
errorCode: mockErrorInstance.name,
|
|
136
|
+
});
|
|
126
137
|
});
|
|
127
138
|
});
|
|
@@ -1,106 +1,121 @@
|
|
|
1
|
-
import { LogMessages } from "../src/logging-wrapper-entities.js";
|
|
2
|
-
import { initializeServer, DEFAULT_METHOD, DEFAULT_PATH, checkExpectedRequestEntry, checkExpectedResponseEntry, parseLogEntry, checkGenericEntryFields } from "./helpers/fastify-test-helpers.js";
|
|
3
1
|
import { REQUEST_ID_HEADER } from "@ogcio/shared-errors";
|
|
4
|
-
import assert from "
|
|
5
|
-
import {
|
|
2
|
+
import { assert, afterEach, describe, it } from "vitest";
|
|
3
|
+
import { LogMessages } from "../src/logging-wrapper-entities.js";
|
|
4
|
+
import {
|
|
5
|
+
DEFAULT_METHOD,
|
|
6
|
+
DEFAULT_PATH,
|
|
7
|
+
checkExpectedRequestEntry,
|
|
8
|
+
checkExpectedResponseEntry,
|
|
9
|
+
checkGenericEntryFields,
|
|
10
|
+
initializeServer,
|
|
11
|
+
parseLogEntry,
|
|
12
|
+
} from "./helpers/fastify-test-helpers.js";
|
|
6
13
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
14
|
+
describe("Logging entries when all works fine are the expected ones", () => {
|
|
15
|
+
it("should pass", async () => {
|
|
16
|
+
const { server, loggingDestination } = initializeServer();
|
|
17
|
+
afterEach(() => server.close());
|
|
10
18
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
19
|
+
const response = await server.inject({
|
|
20
|
+
method: DEFAULT_METHOD,
|
|
21
|
+
url: DEFAULT_PATH,
|
|
22
|
+
});
|
|
23
|
+
assert.ok(typeof response !== "undefined");
|
|
24
|
+
assert.equal(response?.statusCode, 200);
|
|
25
|
+
const loggedRecords = loggingDestination.getLoggedRecords();
|
|
26
|
+
assert.equal(loggedRecords.length, 3);
|
|
27
|
+
checkExpectedRequestEntry({
|
|
28
|
+
requestLogEntry: loggedRecords[0],
|
|
29
|
+
});
|
|
30
|
+
checkExpectedResponseEntry({
|
|
31
|
+
responseLogEntry: loggedRecords[1],
|
|
32
|
+
responseStatusCode: 200,
|
|
33
|
+
});
|
|
34
|
+
checkExpectedResponseEntry({
|
|
35
|
+
responseLogEntry: loggedRecords[2],
|
|
36
|
+
responseStatusCode: 200,
|
|
37
|
+
expectedMessage: LogMessages.ApiTrack,
|
|
38
|
+
});
|
|
30
39
|
});
|
|
31
40
|
});
|
|
32
41
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
42
|
+
describe("Request id is overriden by header", () => {
|
|
43
|
+
it("should pass", async () => {
|
|
44
|
+
const { server, loggingDestination } = initializeServer();
|
|
45
|
+
afterEach(() => server.close());
|
|
46
|
+
const customRequestId = "Another request id";
|
|
47
|
+
const response = await server.inject({
|
|
48
|
+
method: DEFAULT_METHOD,
|
|
49
|
+
url: DEFAULT_PATH,
|
|
50
|
+
headers: { [REQUEST_ID_HEADER]: customRequestId },
|
|
51
|
+
});
|
|
52
|
+
assert.ok(typeof response !== "undefined");
|
|
53
|
+
assert.equal(response?.statusCode, 200);
|
|
54
|
+
const logged = loggingDestination.getLoggedRecords();
|
|
55
|
+
checkExpectedRequestEntry({
|
|
56
|
+
requestLogEntry: logged[0],
|
|
57
|
+
inputHeaders: { [REQUEST_ID_HEADER]: customRequestId },
|
|
58
|
+
});
|
|
59
|
+
const parsedEntry = parseLogEntry(logged[0]);
|
|
60
|
+
assert.deepEqual(parsedEntry.request_id, customRequestId);
|
|
48
61
|
});
|
|
49
|
-
const parsedEntry = parseLogEntry(logged[0]);
|
|
50
|
-
assert.deepEqual(parsedEntry.request_id, customRequestId);
|
|
51
62
|
});
|
|
52
63
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
64
|
+
describe("Logging context is reset between requests", () => {
|
|
65
|
+
it("should pass", async () => {
|
|
66
|
+
const { server, loggingDestination } = initializeServer();
|
|
67
|
+
afterEach(() => server.close());
|
|
56
68
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
69
|
+
let response = await server.inject({
|
|
70
|
+
method: DEFAULT_METHOD,
|
|
71
|
+
url: DEFAULT_PATH,
|
|
72
|
+
});
|
|
61
73
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
74
|
+
assert.ok(typeof response !== "undefined");
|
|
75
|
+
assert.equal(response?.statusCode, 200);
|
|
76
|
+
let loggedRecords = loggingDestination.getLoggedRecords();
|
|
77
|
+
assert.equal(loggedRecords.length, 3);
|
|
78
|
+
let parsedResponse = parseLogEntry(loggedRecords[1]);
|
|
79
|
+
assert.ok(typeof parsedResponse.response !== "undefined");
|
|
68
80
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
81
|
+
response = await server.inject({
|
|
82
|
+
method: DEFAULT_METHOD,
|
|
83
|
+
url: DEFAULT_PATH,
|
|
84
|
+
});
|
|
85
|
+
assert.ok(typeof response !== "undefined");
|
|
86
|
+
assert.equal(response?.statusCode, 200);
|
|
87
|
+
loggedRecords = loggingDestination.getLoggedRecords();
|
|
88
|
+
assert.equal(loggedRecords.length, 6);
|
|
89
|
+
// 3 is the New Request for 2nd call
|
|
90
|
+
parsedResponse = parseLogEntry(loggedRecords[3]);
|
|
91
|
+
// if undefined it means that the logging context
|
|
92
|
+
// has been reset between requests
|
|
93
|
+
assert.ok(typeof parsedResponse.response === "undefined");
|
|
72
94
|
});
|
|
73
|
-
assert.ok(typeof response !== "undefined");
|
|
74
|
-
assert.equal(response?.statusCode, 200);
|
|
75
|
-
loggedRecords = loggingDestination.getLoggedRecords();
|
|
76
|
-
assert.equal(loggedRecords.length, 6);
|
|
77
|
-
// 3 is the New Request for 2nd call
|
|
78
|
-
parsedResponse = parseLogEntry(loggedRecords[3]);
|
|
79
|
-
// if undefined it means that the logging context
|
|
80
|
-
// has been reset between requests
|
|
81
|
-
assert.ok(typeof parsedResponse.response === "undefined");
|
|
82
95
|
});
|
|
83
96
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
97
|
+
describe("Additional logs are correctly written", () => {
|
|
98
|
+
it("should pass", async () => {
|
|
99
|
+
const { server, loggingDestination } = initializeServer();
|
|
100
|
+
afterEach(() => server.close());
|
|
101
|
+
const logMessage = "Testing additional logs";
|
|
88
102
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
103
|
+
const response = await server.inject({
|
|
104
|
+
method: "POST",
|
|
105
|
+
url: "/logs",
|
|
106
|
+
body: { log_entry: logMessage },
|
|
107
|
+
});
|
|
94
108
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
109
|
+
assert.ok(typeof response !== "undefined");
|
|
110
|
+
assert.equal(response?.statusCode, 200);
|
|
111
|
+
const loggedRecords = loggingDestination.getLoggedRecords();
|
|
112
|
+
assert.equal(loggedRecords.length, 4);
|
|
113
|
+
const parsedAdditional = parseLogEntry(loggedRecords[1]);
|
|
114
|
+
checkGenericEntryFields({
|
|
115
|
+
parsedEntry: parsedAdditional,
|
|
116
|
+
expectedLevelName: "INFO",
|
|
117
|
+
expectedMessage: logMessage,
|
|
118
|
+
});
|
|
119
|
+
assert.ok(typeof parsedAdditional.request !== "undefined");
|
|
104
120
|
});
|
|
105
|
-
assert.ok(typeof parsedAdditional.request !== "undefined");
|
|
106
121
|
});
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
+
import { createError } from "@fastify/error";
|
|
2
|
+
import { httpErrors } from "@fastify/sensible";
|
|
1
3
|
import Fastify from "fastify";
|
|
4
|
+
import type { DestinationStream } from "pino";
|
|
2
5
|
import {
|
|
3
6
|
getLoggingConfiguration,
|
|
4
7
|
initializeLoggingHooks,
|
|
5
8
|
} from "../../src/fastify-logging-wrapper.js";
|
|
6
|
-
import { DestinationStream } from "pino";
|
|
7
|
-
import { createError } from "@fastify/error";
|
|
8
|
-
import { httpErrors } from "@fastify/sensible";
|
|
9
9
|
|
|
10
10
|
export const buildFastify = (loggerDestination?: DestinationStream) => {
|
|
11
11
|
const server = Fastify({
|
|
12
|
-
...getLoggingConfiguration(
|
|
12
|
+
...getLoggingConfiguration({
|
|
13
|
+
loggerDestination: loggerDestination,
|
|
14
|
+
}),
|
|
13
15
|
});
|
|
14
16
|
|
|
15
17
|
initializeLoggingHooks(server);
|
|
@@ -20,17 +22,17 @@ export const buildFastify = (loggerDestination?: DestinationStream) => {
|
|
|
20
22
|
|
|
21
23
|
server.get("/error", async (request, _reply) => {
|
|
22
24
|
const parsed = request.query as { [x: string]: unknown };
|
|
23
|
-
const requestedStatusCode = Number(parsed
|
|
24
|
-
const requestedMessage = String(parsed
|
|
25
|
+
const requestedStatusCode = Number(parsed.status_code ?? "500");
|
|
26
|
+
const requestedMessage = String(parsed.error_message ?? "WHOOOPS");
|
|
25
27
|
|
|
26
|
-
if (!parsed
|
|
28
|
+
if (!parsed.status_code) {
|
|
27
29
|
throw new Error(requestedMessage);
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
throw createError(
|
|
31
33
|
"CUSTOM_CODE",
|
|
32
34
|
requestedMessage as string,
|
|
33
|
-
requestedStatusCode as number
|
|
35
|
+
requestedStatusCode as number,
|
|
34
36
|
)();
|
|
35
37
|
});
|
|
36
38
|
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { FastifyInstance } from "fastify";
|
|
1
|
+
import type { FastifyInstance } from "fastify";
|
|
2
|
+
import { assert } from "vitest";
|
|
3
|
+
import {
|
|
4
|
+
type LogErrorClasses,
|
|
5
|
+
LogMessages,
|
|
6
|
+
} from "../../src/logging-wrapper-entities.js";
|
|
2
7
|
import { buildFastify } from "./build-fastify.js";
|
|
3
8
|
import {
|
|
4
|
-
TestingLoggerDestination,
|
|
9
|
+
type TestingLoggerDestination,
|
|
5
10
|
getTestingDestinationLogger,
|
|
6
11
|
} from "./build-logger.js";
|
|
7
|
-
import {
|
|
8
|
-
LogErrorClasses,
|
|
9
|
-
LogMessages,
|
|
10
|
-
} from "../../src/logging-wrapper-entities.js";
|
|
11
|
-
import assert from 'node:assert/strict';
|
|
12
12
|
|
|
13
13
|
export const DEFAULT_HOSTNAME = "localhost";
|
|
14
14
|
export const DEFAULT_PORT = 80;
|
|
@@ -33,7 +33,8 @@ export const initializeServer = (): {
|
|
|
33
33
|
return { server, loggingDestination };
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
-
//
|
|
36
|
+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
37
|
+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
37
38
|
export const parseLogEntry = (logEntry: string): { [x: string]: any } =>
|
|
38
39
|
JSON.parse(logEntry);
|
|
39
40
|
|
|
@@ -77,7 +78,14 @@ export const checkExpectedRequestEntry = (params: {
|
|
|
77
78
|
assert.equal(parsed.request?.path, params.inputPath);
|
|
78
79
|
assert.equal(parsed.request?.hostname, DEFAULT_HOSTNAME);
|
|
79
80
|
assert.equal(parsed.request?.port, DEFAULT_PORT);
|
|
80
|
-
assert.deepStrictEqual(
|
|
81
|
+
assert.deepStrictEqual(
|
|
82
|
+
parsed.request?.query_params,
|
|
83
|
+
params.inputQueryParams ?? {},
|
|
84
|
+
);
|
|
85
|
+
assert.deepStrictEqual(
|
|
86
|
+
parsed.request?.query_params,
|
|
87
|
+
params.inputQueryParams ?? {},
|
|
88
|
+
);
|
|
81
89
|
assert.deepStrictEqual(parsed.request?.headers, {
|
|
82
90
|
...DEFAULT_REQUEST_HEADERS,
|
|
83
91
|
...(params.inputHeaders ?? {}),
|
|
@@ -111,7 +119,14 @@ export const checkExpectedResponseEntry = (params: {
|
|
|
111
119
|
assert.equal(parsed.request.path, params.inputPath);
|
|
112
120
|
assert.equal(parsed.request.hostname, DEFAULT_HOSTNAME);
|
|
113
121
|
assert.equal(parsed.request.port, DEFAULT_PORT);
|
|
114
|
-
assert.deepStrictEqual(
|
|
122
|
+
assert.deepStrictEqual(
|
|
123
|
+
parsed.request.query_params,
|
|
124
|
+
params.inputQueryParams ?? {},
|
|
125
|
+
);
|
|
126
|
+
assert.deepStrictEqual(
|
|
127
|
+
parsed.request.query_params,
|
|
128
|
+
params.inputQueryParams ?? {},
|
|
129
|
+
);
|
|
115
130
|
assert.ok(typeof parsed.response !== "undefined");
|
|
116
131
|
assert.equal(parsed.response.status_code, params.responseStatusCode);
|
|
117
132
|
assert.equal(parsed.response.headers["content-type"], DEFAULT_CONTENT_TYPE);
|
|
@@ -177,7 +192,14 @@ export const checkExpectedErrorEntry = (params: {
|
|
|
177
192
|
assert.equal(parsed.request?.path, params.inputPath);
|
|
178
193
|
assert.equal(parsed.request?.hostname, DEFAULT_HOSTNAME);
|
|
179
194
|
assert.equal(parsed.request?.port, DEFAULT_PORT);
|
|
180
|
-
assert.deepStrictEqual(
|
|
195
|
+
assert.deepStrictEqual(
|
|
196
|
+
parsed.request?.query_params,
|
|
197
|
+
params.inputQueryParams ?? {},
|
|
198
|
+
);
|
|
199
|
+
assert.deepStrictEqual(
|
|
200
|
+
parsed.request?.query_params,
|
|
201
|
+
params.inputQueryParams ?? {},
|
|
202
|
+
);
|
|
181
203
|
assert.ok(typeof parsed.error !== "undefined");
|
|
182
204
|
assert.equal(parsed.error.class, params.errorClass);
|
|
183
205
|
assert.equal(parsed.error.code, params.errorCode);
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { Level } from "pino";
|
|
2
|
-
import { getLoggerConfiguration } from "../src/logging-wrapper.js";
|
|
3
|
-
import { buildLogger } from "./helpers/build-logger.js";
|
|
4
1
|
import { hostname } from "os";
|
|
2
|
+
import { assert, describe, it } from "vitest";
|
|
5
3
|
import { REDACTED_VALUE } from "../src/logging-wrapper-entities.js";
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
4
|
+
import { getLoggerConfiguration } from "../src/logging-wrapper.js";
|
|
5
|
+
import { buildLogger } from "./helpers/build-logger.js";
|
|
8
6
|
|
|
9
7
|
const getRandomFieldValue = () => Math.random().toString(36).slice(2);
|
|
10
8
|
|
|
@@ -106,63 +104,74 @@ const methodsDataProvider = [
|
|
|
106
104
|
},
|
|
107
105
|
];
|
|
108
106
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
107
|
+
describe("Basic format is the expected one", () => {
|
|
108
|
+
it("should pass", async () => {
|
|
109
|
+
const { logger, loggedRecordsMethod } = buildLogger({
|
|
110
|
+
...getLoggerConfiguration("debug"),
|
|
111
|
+
});
|
|
112
|
+
logger.debug("test message");
|
|
113
|
+
logger.info("another message");
|
|
115
114
|
|
|
116
|
-
|
|
117
|
-
|
|
115
|
+
const loggedRecords = loggedRecordsMethod();
|
|
116
|
+
assert.strictEqual(loggedRecords.length, 2);
|
|
118
117
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
118
|
+
const parsed = JSON.parse(loggedRecords[0]);
|
|
119
|
+
assert.strictEqual(typeof parsed.timestamp, "number");
|
|
120
|
+
assert.ok(
|
|
121
|
+
parsed.timestamp > Date.now() - 2000,
|
|
122
|
+
"the timestamp must be newer than 2 seconds ago",
|
|
123
|
+
);
|
|
124
|
+
// biome-ignore lint/performance/noDelete: Would change behaviour of the test
|
|
125
|
+
delete parsed.timestamp;
|
|
126
|
+
assert.deepStrictEqual(parsed, {
|
|
127
|
+
level: 20,
|
|
128
|
+
level_name: "DEBUG",
|
|
129
|
+
hostname: hostname(),
|
|
130
|
+
message: "test message",
|
|
131
|
+
});
|
|
131
132
|
});
|
|
132
133
|
});
|
|
133
134
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
135
|
+
describe("Fields are redacted as expected", () => {
|
|
136
|
+
it("should pass", async () => {
|
|
137
|
+
const { logger, loggedRecordsMethod } = buildLogger({
|
|
138
|
+
...getLoggerConfiguration(),
|
|
139
|
+
});
|
|
140
|
+
logger.warn(toRedactFields.input_value);
|
|
139
141
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
142
|
+
const loggedRecords = loggedRecordsMethod();
|
|
143
|
+
const parsed = JSON.parse(loggedRecords[0]);
|
|
144
|
+
// biome-ignore lint/performance/noDelete: Would change behaviour of the test
|
|
145
|
+
delete parsed.hostname;
|
|
146
|
+
// biome-ignore lint/performance/noDelete: Would change behaviour of the test
|
|
147
|
+
delete parsed.level;
|
|
148
|
+
// biome-ignore lint/performance/noDelete: Would change behaviour of the test
|
|
149
|
+
delete parsed.level_name;
|
|
150
|
+
// biome-ignore lint/performance/noDelete: Would change behaviour of the test
|
|
151
|
+
delete parsed.timestamp;
|
|
146
152
|
|
|
147
|
-
|
|
153
|
+
assert.deepStrictEqual(parsed, toRedactFields.expected_output);
|
|
154
|
+
});
|
|
148
155
|
});
|
|
149
156
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
157
|
+
for (const methodDataProvider of methodsDataProvider) {
|
|
158
|
+
describe(`Methods are writing correct levels - ${methodDataProvider.method}`, () => {
|
|
159
|
+
it("should pass", async () => {
|
|
160
|
+
const { logger, loggedRecordsMethod } = buildLogger({
|
|
161
|
+
...getLoggerConfiguration("trace"),
|
|
162
|
+
});
|
|
155
163
|
|
|
156
|
-
|
|
164
|
+
logger[methodDataProvider.method]("test");
|
|
157
165
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
166
|
+
const loggedRecords = loggedRecordsMethod();
|
|
167
|
+
assert.strictEqual(loggedRecords.length, 1);
|
|
168
|
+
const parsed = JSON.parse(loggedRecords[0]);
|
|
161
169
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
);
|
|
170
|
+
assert.strictEqual(parsed.level, methodDataProvider.expected.level);
|
|
171
|
+
assert.strictEqual(
|
|
172
|
+
parsed.level_name,
|
|
173
|
+
methodDataProvider.expected.level_name,
|
|
174
|
+
);
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FastifyServerOptions, FastifyInstance } from "fastify";
|
|
2
|
-
import { DestinationStream } from "pino";
|
|
1
|
+
import type { FastifyServerOptions, FastifyInstance } from "fastify";
|
|
2
|
+
import { type DestinationStream } from "pino";
|
|
3
3
|
export declare const initializeLoggingHooks: (server: FastifyInstance) => void;
|
|
4
4
|
export declare const getLoggingConfiguration: (loggerDestination?: DestinationStream) => FastifyServerOptions;
|
|
5
5
|
//# sourceMappingURL=fastify-logging-wrapper.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fastify-logging-wrapper.d.ts","sourceRoot":"","sources":["../src/fastify-logging-wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"fastify-logging-wrapper.d.ts","sourceRoot":"","sources":["../src/fastify-logging-wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAcrE,OAAO,EAAQ,KAAK,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAKpD,eAAO,MAAM,sBAAsB,WAAY,eAAe,KAAG,IA6BhE,CAAC;AAEF,eAAO,MAAM,uBAAuB,uBACd,iBAAiB,KACpC,oBAMD,CAAC"}
|
|
@@ -25,7 +25,7 @@ export const initializeLoggingHooks = (server) => {
|
|
|
25
25
|
});
|
|
26
26
|
};
|
|
27
27
|
export const getLoggingConfiguration = (loggerDestination) => ({
|
|
28
|
-
|
|
28
|
+
logger: pino(getLoggerConfiguration(), loggerDestination),
|
|
29
29
|
disableRequestLogging: true,
|
|
30
30
|
genReqId: () => hyperidInstance(),
|
|
31
31
|
requestIdLogLabel: REQUEST_ID_LOG_LABEL,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fastify-logging-wrapper.js","sourceRoot":"","sources":["../src/fastify-logging-wrapper.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAA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iBAAiB,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;QACvC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QACrC,uCAAuC;QACvC,KAAK,CAAC,GAAG,CAAC,IAAI,CACZ,EAAE,KAAK,EAAE,6BAA6B,EAAE,EAAE,EAC1C,WAAW,CAAC,QAAQ,CACrB,CAAC;QACF,mBAAmB,EAAE,CAAC;QACtB,IAAI,EAAE,CAAC;IACT,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QACzD,iBAAiB,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QAE7B,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,sBAAsB,EAAE,EAAE,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;QAE1E,IAAI,EAAE,CAAC;IACT,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACrC,iBAAqC,EACf,EAAE,CAAC,CAAC;IAC1B,MAAM,EAAE,IAAI,CAAC,sBAAsB,EAAE,EAAE,iBAAiB,CAAC;IACzD,qBAAqB,EAAE,IAAI;IAC3B,QAAQ,EAAE,GAAG,EAAE,CAAC,eAAe,EAAE;IACjC,iBAAiB,EAAE,oBAAoB;IACvC,eAAe,EAAE,iBAAiB;CACnC,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { getLoggingConfiguration, initializeLoggingHooks, } from "./fastify-logging-wrapper.js";
|
|
2
2
|
export { toLoggingError, LogMessages, LoggingError, } from "./logging-wrapper-entities.js";
|
|
3
|
-
export { getLoggingContextError, setLoggingContext } from "./logging-wrapper.js";
|
|
3
|
+
export { getLoggingContextError, setLoggingContext, } from "./logging-wrapper.js";
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,cAAc,EACd,WAAW,EACX,YAAY,GACb,MAAM,+BAA+B,CAAC;AAEvC,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,cAAc,EACd,WAAW,EACX,YAAY,GACb,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EACL,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { getLoggingConfiguration, initializeLoggingHooks, } from "./fastify-logging-wrapper.js";
|
|
2
2
|
export { toLoggingError, LogMessages, } from "./logging-wrapper-entities.js";
|
|
3
|
-
export { getLoggingContextError, setLoggingContext } from "./logging-wrapper.js";
|
|
3
|
+
export { getLoggingContextError, setLoggingContext, } from "./logging-wrapper.js";
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,cAAc,EACd,WAAW,GAEZ,MAAM,+BAA+B,CAAC;AAEvC,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,cAAc,EACd,WAAW,GAEZ,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EACL,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,sBAAsB,CAAC"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { FastifyError } from "fastify";
|
|
2
|
-
import { HttpError } from "@fastify/sensible";
|
|
1
|
+
import type { FastifyError } from "fastify";
|
|
2
|
+
import type { HttpError } from "@fastify/sensible";
|
|
3
3
|
export interface LoggingRequest {
|
|
4
4
|
scheme: string;
|
|
5
5
|
method: string;
|
|
6
6
|
path: string | undefined;
|
|
7
7
|
hostname: string;
|
|
8
8
|
query_params: unknown;
|
|
9
|
-
port: number;
|
|
10
9
|
[key: string]: unknown;
|
|
11
10
|
}
|
|
12
11
|
export interface FullLoggingRequest extends LoggingRequest {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logging-wrapper-entities.d.ts","sourceRoot":"","sources":["../src/logging-wrapper-entities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"logging-wrapper-entities.d.ts","sourceRoot":"","sources":["../src/logging-wrapper-entities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAGnD,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,OAAO,CAAC;IACtB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,kBAAmB,SAAQ,cAAc;IACxD,OAAO,EAAE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":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"logging-wrapper-entities.js","sourceRoot":"","sources":["../src/logging-wrapper-entities.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAqC1C,MAAM,CAAN,IAAY,WAKX;AALD,WAAY,WAAW;IACrB,yCAA0B,CAAA;IAC1B,oCAAqB,CAAA;IACrB,8BAAe,CAAA;IACf,qCAAsB,CAAA;AACxB,CAAC,EALW,WAAW,KAAX,WAAW,QAKtB;AAED,MAAM,CAAN,IAAY,eAMX;AAND,WAAY,eAAe;IACzB,+CAA4B,CAAA;IAC5B,uDAAoC,CAAA;IACpC,iDAA8B,CAAA;IAC9B,iDAA8B,CAAA;IAC9B,iDAA8B,CAAA;AAChC,CAAC,EANW,eAAe,KAAf,eAAe,QAM1B;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,YAAY,CAAC;AAE3C,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,mCAAmC;IACnC,wBAAwB;IACxB,4BAA4B;IAC5B,qBAAqB;IACrB,yBAAyB;IACzB,kCAAkC;CACnC,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,SAAS,CAAC;AAErC,MAAM,CAAC,MAAM,oBAAoB,GAAG,YAAY,CAAC;AAEjD,MAAM,wBAAwB,GAAG,qBAAqB,CAAC;AAEvD,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,KAA+B,EACjB,EAAE;IAChB,MAAM,MAAM,GAAG;QACb,KAAK,EAAE,eAAe,CAAC,KAAK,CAAC;QAC7B,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,KAAK,EAAE,KAAK,CAAC,KAAK;KACnB,CAAC;IAEF,IAAI,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;QACvB,MAAM,WAAW,GAAG,KAAK,CAAC,WAAW,IAAI,KAAK,CAAC,MAAM,CAAC;QACtD,MAAM,MAAM,GAAG,WAAW;YACxB,CAAC,CAAC,EAAE,MAAM,EAAE,oBAAoB,CAAC,WAAW,CAAC,EAAE;YAC/C,CAAC,CAAC,EAAE,CAAC;QAEP,OAAO;YACL,GAAG,MAAM;YACT,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,OAAO,EAAE,KAAK,CAAC,YAAY;YAC3B,GAAG,MAAM;SACV,CAAC;IACJ,CAAC;IAED,OAAO;QACL,GAAG,MAAM;QACT,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,wBAAwB;KAC7C,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG,CAAC,KAA+B,EAAmB,EAAE;IAC3E,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;QACtB,OAAO,eAAe,CAAC,YAAY,CAAC;IACtC,CAAC;IAED,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAE5C,IAAI,UAAU,KAAK,GAAG,EAAE,CAAC;QACvB,OAAO,eAAe,CAAC,YAAY,CAAC;IACtC,CAAC;IAED,IAAI,UAAU,IAAI,GAAG,EAAE,CAAC;QACtB,OAAO,eAAe,CAAC,WAAW,CAAC;IACrC,CAAC;IAED,IAAI,UAAU,KAAK,GAAG,EAAE,CAAC;QACvB,OAAO,eAAe,CAAC,eAAe,CAAC;IACzC,CAAC;IAED,IAAI,UAAU,IAAI,GAAG,EAAE,CAAC;QACtB,OAAO,eAAe,CAAC,YAAY,CAAC;IACtC,CAAC;IAED,OAAO,eAAe,CAAC,YAAY,CAAC;AACtC,CAAC,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { FastifyRequest, FastifyReply, FastifyError } from "fastify";
|
|
2
|
-
import { LoggingContext, FullLoggingRequest, LoggingError } from "./logging-wrapper-entities.js";
|
|
3
|
-
import { LogLevel, PinoLoggerOptions } from "fastify/types/logger.js";
|
|
4
|
-
import { HttpError } from "@fastify/sensible";
|
|
1
|
+
import type { FastifyRequest, FastifyReply, FastifyError } from "fastify";
|
|
2
|
+
import { type LoggingContext, type FullLoggingRequest, type LoggingError } from "./logging-wrapper-entities.js";
|
|
3
|
+
import type { LogLevel, PinoLoggerOptions } from "fastify/types/logger.js";
|
|
4
|
+
import type { HttpError } from "@fastify/sensible";
|
|
5
5
|
type INPUT_ERROR_TYPES = FastifyError | HttpError;
|
|
6
6
|
export declare const getLoggingContext: (params: {
|
|
7
7
|
includeError: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logging-wrapper.d.ts","sourceRoot":"","sources":["../src/logging-wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"logging-wrapper.d.ts","sourceRoot":"","sources":["../src/logging-wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE1E,OAAO,EACL,KAAK,cAAc,EAEnB,KAAK,kBAAkB,EAEvB,KAAK,YAAY,EAKlB,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAInD,KAAK,iBAAiB,GAAG,YAAY,GAAG,SAAS,CAAC;AAElD,eAAO,MAAM,iBAAiB,WAAY;IACxC,YAAY,EAAE,OAAO,CAAC;CACvB,KAAG,cAGyC,CAAC;AAE9C,eAAO,MAAM,iBAAiB,WAAY;IACxC,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,KAAK,CAAC,EAAE,iBAAiB,CAAC;CAC3B,KAAG,IAUH,CAAC;AAEF,eAAO,MAAM,mBAAmB,QAAO,IA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AE,cAAc;QACrB,MAAM,EAAE,cAAc;KACvB;IACD,SAAS,EAAE,KAAK;IAChB,UAAU,EAAE;QACV,KAAK,EAAE,CAAC,IAAY,EAAE,QAAgB,EAAE,EAAE,CAAC,CAAC;YAC1C,KAAK,EAAE,QAAQ;YACf,UAAU,EAAE,IAAI,CAAC,WAAW,EAAE;SAC/B,CAAC;KACH;IACD,KAAK,EAAE,YAAY;CACpB,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ogcio/fastify-logging-wrapper",
|
|
3
|
-
"version": "5.0
|
|
3
|
+
"version": "5.1.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "rm -rf dist tsconfig.prod.tsbuildinfo tsconfig.tsbuildinfo && tsc -p tsconfig.prod.json",
|
|
9
|
-
"test": "
|
|
9
|
+
"test": "vitest run --coverage --outputFile=results.xml"
|
|
10
10
|
},
|
|
11
11
|
"keywords": [],
|
|
12
12
|
"author": {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"@fastify/error": "^4.0.0",
|
|
20
20
|
"@fastify/sensible": "^6.0.1",
|
|
21
21
|
"@ogcio/shared-errors": "^1.0.0",
|
|
22
|
-
"fastify": "^5.
|
|
22
|
+
"fastify": "^5.1.0",
|
|
23
23
|
"hyperid": "^3.3.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FastifyServerOptions, FastifyInstance } from "fastify";
|
|
1
|
+
import type { FastifyServerOptions, FastifyInstance } from "fastify";
|
|
2
2
|
import hyperid from "hyperid";
|
|
3
3
|
import {
|
|
4
4
|
LogMessages,
|
|
@@ -12,8 +12,9 @@ import {
|
|
|
12
12
|
resetLoggingContext,
|
|
13
13
|
setLoggingContext,
|
|
14
14
|
} from "./logging-wrapper.js";
|
|
15
|
-
import { pino, DestinationStream } from "pino";
|
|
15
|
+
import { pino, type DestinationStream } from "pino";
|
|
16
16
|
import { REQUEST_ID_HEADER } from "@ogcio/shared-errors";
|
|
17
|
+
import type { PinoLoggerOptions } from "fastify/types/logger.js";
|
|
17
18
|
|
|
18
19
|
const hyperidInstance = hyperid({ fixedLength: true, urlSafe: true });
|
|
19
20
|
|
|
@@ -48,12 +49,27 @@ export const initializeLoggingHooks = (server: FastifyInstance): void => {
|
|
|
48
49
|
});
|
|
49
50
|
};
|
|
50
51
|
|
|
51
|
-
export const getLoggingConfiguration = (
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
52
|
+
export const getLoggingConfiguration = (customConfig?: {
|
|
53
|
+
pinoOptions?: PinoLoggerOptions;
|
|
54
|
+
loggerDestination?: DestinationStream;
|
|
55
|
+
}): FastifyServerOptions => {
|
|
56
|
+
if (customConfig)
|
|
57
|
+
return {
|
|
58
|
+
loggerInstance: pino(
|
|
59
|
+
{ ...getLoggerConfiguration(), ...(customConfig?.pinoOptions ?? {}) },
|
|
60
|
+
customConfig?.loggerDestination,
|
|
61
|
+
),
|
|
62
|
+
disableRequestLogging: true,
|
|
63
|
+
genReqId: () => hyperidInstance(),
|
|
64
|
+
requestIdLogLabel: REQUEST_ID_LOG_LABEL,
|
|
65
|
+
requestIdHeader: REQUEST_ID_HEADER,
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
logger: getLoggerConfiguration(),
|
|
70
|
+
disableRequestLogging: true,
|
|
71
|
+
genReqId: () => hyperidInstance(),
|
|
72
|
+
requestIdLogLabel: REQUEST_ID_LOG_LABEL,
|
|
73
|
+
requestIdHeader: REQUEST_ID_HEADER,
|
|
74
|
+
};
|
|
75
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { FastifyError } from "fastify";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
} from "
|
|
5
|
-
import { HttpError} from "@fastify/sensible";
|
|
6
|
-
import {isHttpError} from "http-errors";
|
|
1
|
+
import type { FastifyError } from "fastify";
|
|
2
|
+
import { parseErrorForLogging } from "@ogcio/shared-errors";
|
|
3
|
+
import type { HttpError } from "@fastify/sensible";
|
|
4
|
+
import { isHttpError } from "http-errors";
|
|
7
5
|
|
|
8
6
|
export interface LoggingRequest {
|
|
9
7
|
scheme: string;
|
|
@@ -102,9 +100,7 @@ export const toLoggingError = (
|
|
|
102
100
|
};
|
|
103
101
|
};
|
|
104
102
|
|
|
105
|
-
const parseErrorClass = (
|
|
106
|
-
error: FastifyError | HttpError,
|
|
107
|
-
): LogErrorClasses => {
|
|
103
|
+
const parseErrorClass = (error: FastifyError | HttpError): LogErrorClasses => {
|
|
108
104
|
if (!error.statusCode) {
|
|
109
105
|
return LogErrorClasses.UnknownError;
|
|
110
106
|
}
|
package/src/logging-wrapper.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { FastifyRequest, FastifyReply, FastifyError } from "fastify";
|
|
1
|
+
import type { FastifyRequest, FastifyReply, FastifyError } from "fastify";
|
|
2
2
|
import { hostname } from "os";
|
|
3
3
|
import {
|
|
4
|
-
LoggingContext,
|
|
5
|
-
LoggingRequest,
|
|
6
|
-
FullLoggingRequest,
|
|
7
|
-
LoggingResponse,
|
|
8
|
-
LoggingError,
|
|
4
|
+
type LoggingContext,
|
|
5
|
+
type LoggingRequest,
|
|
6
|
+
type FullLoggingRequest,
|
|
7
|
+
type LoggingResponse,
|
|
8
|
+
type LoggingError,
|
|
9
9
|
REDACTED_VALUE,
|
|
10
10
|
REDACTED_PATHS,
|
|
11
11
|
MESSAGE_KEY,
|
|
12
12
|
toLoggingError,
|
|
13
13
|
} from "./logging-wrapper-entities.js";
|
|
14
|
-
import { LogLevel, PinoLoggerOptions } from "fastify/types/logger.js";
|
|
15
|
-
import { HttpError } from "@fastify/sensible";
|
|
14
|
+
import type { LogLevel, PinoLoggerOptions } from "fastify/types/logger.js";
|
|
15
|
+
import type { HttpError } from "@fastify/sensible";
|
|
16
16
|
|
|
17
17
|
const loggingContext: LoggingContext = {};
|
|
18
18
|
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { defineConfig } from "vitest/config";
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
test: {
|
|
5
|
+
reporters: "junit",
|
|
6
|
+
coverage: {
|
|
7
|
+
reporter: ["text"],
|
|
8
|
+
provider: "istanbul",
|
|
9
|
+
},
|
|
10
|
+
|
|
11
|
+
include: [
|
|
12
|
+
"**/@(test?(s)|__test?(s)__)/**/*.test.@(js|cjs|mjs|tap|cts|jsx|mts|ts|tsx)",
|
|
13
|
+
"**/*.@(test?(s)|spec).@(js|cjs|mjs|tap|cts|jsx|mts|ts|tsx)",
|
|
14
|
+
"**/test?(s).@(js|cjs|mjs|tap|cts|jsx|mts|ts|tsx)",
|
|
15
|
+
],
|
|
16
|
+
exclude: ["**/@(fixture*(s)|dist|node_modules)/**"],
|
|
17
|
+
maxConcurrency: 1,
|
|
18
|
+
testTimeout: 30000, // Timeout in milliseconds (30 seconds)
|
|
19
|
+
},
|
|
20
|
+
});
|