@ogcio/fastify-logging-wrapper 5.1.2 → 5.2.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/README.md +13 -3
- package/package.json +4 -4
- package/tsconfig.json +1 -1
package/README.md
CHANGED
|
@@ -5,20 +5,24 @@ This logging wrapper goal is to standardize the records written by our Fastify s
|
|
|
5
5
|
## How to
|
|
6
6
|
|
|
7
7
|
To use this package three steps are needed:
|
|
8
|
+
|
|
8
9
|
- install the package with
|
|
9
|
-
|
|
10
|
+
|
|
11
|
+
```bash
|
|
10
12
|
npm i @ogcio/fastify-logging-wrapper
|
|
11
13
|
```
|
|
12
14
|
|
|
13
15
|
- use the `getLoggingConfiguration()` method to get the configuration for the `fastify` server
|
|
14
|
-
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
15
18
|
const server = fastify({
|
|
16
19
|
...getLoggingConfiguration()
|
|
17
20
|
});
|
|
18
21
|
```
|
|
19
22
|
|
|
20
23
|
- after the server is initialized, invoke the `initializeLoggingHooks(server)` to setup the needed `fastify` hooks
|
|
21
|
-
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
22
26
|
initializeLoggingHooks(server);
|
|
23
27
|
```
|
|
24
28
|
|
|
@@ -29,15 +33,21 @@ That's it! Just log as you usually do!
|
|
|
29
33
|
We will have 3 mandatory log entries that will be written for each request the service manages.
|
|
30
34
|
|
|
31
35
|
Those 3 records are:
|
|
36
|
+
|
|
32
37
|
- **New Request**, written when a request is received
|
|
38
|
+
|
|
33
39
|
```
|
|
34
40
|
{"level":30,"level_name":"INFO","hostname":"hostname","request_id":"q9Y6NwwbRimle4TxcXRPkQ-0000000000","timestamp":1713868947766,"request":{"scheme":"http","method":"GET","path":"/ping","hostname":"localhost:80","query_params":{},"headers":{"user-agent":"lightMyRequest","host":"localhost:80"},"client_ip":"127.0.0.1","user_agent":"lightMyRequest"},"message":"NEW_REQUEST"}
|
|
35
41
|
```
|
|
42
|
+
|
|
36
43
|
- **Response**, containing most of the response data
|
|
44
|
+
|
|
37
45
|
```
|
|
38
46
|
{"level":30,"level_name":"INFO","hostname":"hostname","request_id":"q9Y6NwwbRimle4TxcXRPkQ-0000000000","timestamp":1713868947769,"request":{"scheme":"http","method":"GET","path":"/ping","hostname":"localhost:80","query_params":{}},"response":{"status_code":200,"headers":{"content-type":"application/json; charset=utf-8","content-length":"17"}},"message":"RESPONSE"}
|
|
39
47
|
```
|
|
48
|
+
|
|
40
49
|
- **API Track**, it contains data about the lifecycle of the request, including errors, if any
|
|
50
|
+
|
|
41
51
|
```
|
|
42
52
|
{"level":30,"level_name":"INFO","hostname":"hostname","request_id":"5c_RLAnSS4y9-Q5STsJyiQ-0000000008","timestamp":1713869128434,"request":{"scheme":"http","method":"GET","path":"/this-path-must-not-exist","hostname":"localhost:80","query_params":{"status_code":"404","error_message":"Not Found"}},"response":{"status_code":404,"headers":{"content-type":"application/json; charset=utf-8","content-length":"107"}},"error":{"class":"REQUEST_ERROR","message":"Not Found","code":"FST_ERR_NOT_FOUND"},"message":"API_TRACK"}
|
|
43
53
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ogcio/fastify-logging-wrapper",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.2.2",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"description": "Enable standardized log entries for each request in fastify",
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@fastify/error": "^4.0.0",
|
|
21
|
-
"@fastify/sensible": "^6.0.
|
|
22
|
-
"@ogcio/shared-errors": "^1.
|
|
23
|
-
"fastify": "^5.1
|
|
21
|
+
"@fastify/sensible": "^6.0.2",
|
|
22
|
+
"@ogcio/shared-errors": "^1.1.0",
|
|
23
|
+
"fastify": "^5.2.1",
|
|
24
24
|
"hyperid": "^3.3.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
package/tsconfig.json
CHANGED