@mielband/logging
v0.2.1
Published
Structured JSON request logging (nestjs-pino) correlated with the API gateway's X-Request-Id
Readme
@mielband/logging
Structured JSON request logging for mielband NestJS services, built on
nestjs-pino. Correlates every
log line with the X-Request-Id header the API gateway already sets on
every proxied request.
Install
Public package, no auth needed:
npm install @mielband/loggingUsage
app.module.ts:
import { LoggingModule } from '@mielband/logging';
@Module({
imports: [LoggingModule /* ... */],
})
export class AppModule {}main.ts:
import { Logger } from '@mielband/logging';
async function bootstrap() {
const app = await NestFactory.create(AppModule, { bufferLogs: true });
app.useLogger(app.get(Logger));
// ...
}Every request now logs one JSON line with request_id, req.method,
req.url, res.statusCode, responseTime — and the response carries back
the same X-Request-Id the request came in with (or a freshly generated one
if the service was hit directly, bypassing the gateway). /health-suffixed
routes are skipped to avoid log noise.
