@nestjs-labs/pino-http-extra 1.0.1 → 1.0.3

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.
Files changed (2) hide show
  1. package/README.md +14 -93
  2. package/package.json +11 -7
package/README.md CHANGED
@@ -5,25 +5,24 @@ Enhanced pino-http with OpenTelemetry, Loki, file rotation and enterprise featur
5
5
  [![npm version](https://img.shields.io/npm/v/@nestjs-labs/pino-http-extra.svg)](https://www.npmjs.com/package/@nestjs-labs/pino-http-extra)
6
6
  [![License](https://img.shields.io/npm/l/@nestjs-labs/pino-http-extra.svg)](https://github.com/nestjs-labs/nestjs-pino-extra/blob/main/LICENSE)
7
7
 
8
- ## 🚀 Features
8
+ ## Features
9
9
 
10
- - 🔍 **OpenTelemetry Integration**: Automatic span and trace ID injection for distributed tracing
11
- - 📊 **Loki Transport**: Send logs to Grafana Loki for centralized log management
12
- - 📁 **File Rotation**: Automatic log file rotation with compression (1GB size, daily rotation)
13
- - 🎨 **Pretty Logging**: Colored and formatted console output for development
14
- - 🔒 **Security**: Automatic redaction of sensitive fields (password, user data)
10
+ - 🔍 **OpenTelemetry Integration**: Automatic span and trace ID injection
11
+ - 📊 **Loki Transport**: Send logs to Grafana Loki
12
+ - 📁 **File Rotation**: Automatic log file rotation with compression
13
+ - 🎨 **Pretty Logging**: Colored and formatted console output
14
+ - 🔒 **Security**: Automatic redaction of sensitive fields
15
15
  - ⚡ **Performance**: High-performance logging with Pino
16
16
  - 🆔 **Request ID**: Automatic request ID generation and tracking
17
17
  - 📈 **Response Time**: Automatic response time tracking
18
- - 🎯 **Smart Log Levels**: Status code-based log level determination
19
18
 
20
- ## 📦 Installation
19
+ ## Installation
21
20
 
22
21
  ```bash
23
22
  npm install @nestjs-labs/pino-http-extra
24
23
  ```
25
24
 
26
- ## 🏃‍♂️ Quick Start
25
+ ## Quick Start
27
26
 
28
27
  ### Basic Setup
29
28
 
@@ -31,7 +30,6 @@ npm install @nestjs-labs/pino-http-extra
31
30
  import pino from 'pino'
32
31
  import pinoHttp from 'pino-http'
33
32
  import { getPinoHttpOption, getMultiDestinationStream } from '@nestjs-labs/pino-http-extra'
34
- import "dotenv/config"
35
33
 
36
34
  const level = process.env.LOG_LEVEL || 'info'
37
35
  const app = process.env.APP_NAME || 'my-app'
@@ -54,9 +52,7 @@ const app = express()
54
52
  const multiStream = getMultiDestinationStream(app, 'info', 'logs/app.log', 'http://loki:3100')
55
53
  const pinoHttpOption = getPinoHttpOption()
56
54
  const pinoHttpLogger = pinoHttp(pinoHttpOption)
57
- const logger = pino(pinoHttpOption, multiStream)
58
55
 
59
- // Use as middleware
60
56
  app.use(pinoHttpLogger)
61
57
 
62
58
  app.get('/', (req, res) => {
@@ -65,7 +61,7 @@ app.get('/', (req, res) => {
65
61
  })
66
62
 
67
63
  app.listen(3000, () => {
68
- logger.info('Server running on port 3000')
64
+ console.log('Server running on port 3000')
69
65
  })
70
66
  ```
71
67
 
@@ -73,7 +69,7 @@ app.listen(3000, () => {
73
69
 
74
70
  ```typescript
75
71
  import Fastify from 'fastify'
76
- import { getPinoHttpOption, getMultiDestinationStream } from '@nestjs-labs/pino-http-extra'
72
+ import { getPinoHttpOption } from '@nestjs-labs/pino-http-extra'
77
73
 
78
74
  const fastify = Fastify({
79
75
  logger: getPinoHttpOption()
@@ -87,24 +83,7 @@ fastify.get('/', async (request, reply) => {
87
83
  fastify.listen({ port: 3000 })
88
84
  ```
89
85
 
90
- ### Advanced Configuration
91
-
92
- ```typescript
93
- import { getPinoHttpOption, getMultiDestinationStream } from '@nestjs-labs/pino-http-extra'
94
-
95
- // Custom OpenTelemetry keys
96
- const options = getPinoHttpOption('debug', 'customSpanId', 'customTraceId')
97
-
98
- // Multi-destination with custom settings
99
- const multiStream = getMultiDestinationStream(
100
- 'my-app', // app name
101
- 'info', // log level
102
- '/var/log/app.log', // file path (optional)
103
- 'http://loki:3100' // loki host (optional)
104
- )
105
- ```
106
-
107
- ## 📚 API Reference
86
+ ## API Reference
108
87
 
109
88
  ### Core Functions
110
89
 
@@ -119,13 +98,6 @@ Get pino-http options with OpenTelemetry integration and security features.
119
98
 
120
99
  **Returns:** `Options` - Configured pino-http options
121
100
 
122
- **Features:**
123
- - Automatic request ID generation
124
- - Response time tracking
125
- - Status code-based log levels
126
- - Sensitive data redaction
127
- - OpenTelemetry integration
128
-
129
101
  #### `getMultiDestinationStream(app, level?, filepath?, loki?)`
130
102
 
131
103
  Create multi-destination stream supporting pretty, file, and Loki outputs.
@@ -138,38 +110,7 @@ Create multi-destination stream supporting pretty, file, and Loki outputs.
138
110
 
139
111
  **Returns:** `MultiStreamRes` - Configured multi-stream
140
112
 
141
- **Features:**
142
- - Pretty console output with colors
143
- - File rotation (1GB size, daily rotation, gzip compression)
144
- - Loki transport with batching
145
-
146
- ### Stream Functions
147
-
148
- #### `createPrettyStreamEntry(app, level)`
149
-
150
- Create pretty console stream entry.
151
-
152
- #### `createFileStreamEntry(app, level, filepath)`
153
-
154
- Create file rotation stream entry.
155
-
156
- #### `createLokiStreamEntry(app, level, host)`
157
-
158
- Create Loki transport stream entry.
159
-
160
- ### Formatters
161
-
162
- #### `getOtelFormatters(spanIdKey?, traceIdKey?)`
163
-
164
- Get OpenTelemetry formatters for automatic span and trace ID injection.
165
-
166
- ### Serializers
167
-
168
- #### `getSerializers()`
169
-
170
- Get enhanced serializers for request/response objects.
171
-
172
- ## 🔧 Examples
113
+ ## Examples
173
114
 
174
115
  ### Custom Logging
175
116
 
@@ -222,26 +163,6 @@ The middleware automatically logs HTTP requests with:
222
163
  }
223
164
  ```
224
165
 
225
- ## 🔒 Security Features
226
-
227
- - **Automatic Redaction**: Sensitive fields are automatically redacted
228
- - **Request ID Tracking**: Each request gets a unique ID for tracing
229
- - **No Sensitive Data**: Passwords and user credentials are never logged
230
-
231
- ## 🚀 Performance
232
-
233
- - **High Performance**: Built on Pino, one of the fastest Node.js loggers
234
- - **Minimal Overhead**: Optimized for production use
235
- - **Async Logging**: Non-blocking log operations
236
- - **Batching**: Loki transport supports batching for better performance
237
-
238
- ## 📄 License
239
-
240
- This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
241
-
242
- ## 🔗 Links
166
+ ## License
243
167
 
244
- - [Documentation](https://nestjs-labs.github.io/nestjs-pino-extra)
245
- - [GitHub Repository](https://github.com/nestjs-labs/nestjs-pino-extra)
246
- - [NPM Package](https://www.npmjs.com/package/@nestjs-labs/pino-http-extra)
247
- - [Issues](https://github.com/nestjs-labs/nestjs-pino-extra/issues)
168
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestjs-labs/pino-http-extra",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Enhanced pino-http with OpenTelemetry, Loki, file rotation and enterprise features",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -8,19 +8,23 @@
8
8
  "exports": {
9
9
  ".": {
10
10
  "import": "./dist/index.js",
11
- "require": "./dist/index.js"
11
+ "require": "./dist/index.js",
12
+ "types": "./dist/index.d.ts"
12
13
  },
13
14
  "./options": {
14
15
  "import": "./dist/options.js",
15
- "require": "./dist/options.js"
16
+ "require": "./dist/options.js",
17
+ "types": "./dist/options.d.ts"
16
18
  },
17
19
  "./streams": {
18
20
  "import": "./dist/streams.js",
19
- "require": "./dist/streams.js"
21
+ "require": "./dist/streams.js",
22
+ "types": "./dist/streams.d.ts"
20
23
  },
21
24
  "./serializers": {
22
25
  "import": "./dist/serializers.js",
23
- "require": "./dist/serializers.js"
26
+ "require": "./dist/serializers.js",
27
+ "types": "./dist/serializers.d.ts"
24
28
  }
25
29
  },
26
30
  "scripts": {
@@ -68,14 +72,14 @@
68
72
  "devDependencies": {
69
73
  "@commitlint/cli": "^19.4.1",
70
74
  "@commitlint/config-conventional": "^19.4.1",
71
- "@nestjs-labs/eslint-config": "^1.0.1",
75
+ "@nestjs-labs/eslint-config": "^1.0.2",
72
76
  "@semantic-release/changelog": "^6.0.3",
73
77
  "@semantic-release/commit-analyzer": "^13.0.1",
74
78
  "@semantic-release/git": "^10.0.1",
75
79
  "@semantic-release/github": "^11.0.3",
76
80
  "@semantic-release/npm": "^12.0.2",
77
81
  "@semantic-release/release-notes-generator": "^14.0.3",
78
- "eslint": "^9.31.0",
82
+ "eslint": "^9.32.0",
79
83
  "prettier": "^3.6.2",
80
84
  "semantic-release": "^24.2.7",
81
85
  "tslib": "^2.8.0",