New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

nestjs-pino

Package Overview
Dependencies
Maintainers
1
Versions
1337
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nestjs-pino - npm Package Compare versions

Comparing version 2.1.0 to 2.2.0-alpha.6310f7

12

LoggerModule.js

@@ -88,7 +88,15 @@ "use strict";

if (Array.isArray(params)) {
return [pinoHttp(...params), bindLoggerMiddleware];
const middleware = pinoHttp(...params);
// @ts-expect-error: root is readonly field, but this is the place where
// it's set actually
PinoLogger_1.PinoLogger.root = middleware.logger;
return [middleware, bindLoggerMiddleware];
}
const middleware = pinoHttp(params);
// @ts-expect-error: root is readonly field, but this is the place where
// it's set actually
PinoLogger_1.PinoLogger.root = middleware.logger;
// FIXME: params type here is pinoHttp.Options | pino.DestinationStream
// pinoHttp has two overloads, each of them takes those types
return [pinoHttp(params), bindLoggerMiddleware];
return [middleware, bindLoggerMiddleware];
}

@@ -95,0 +103,0 @@ function bindLoggerMiddleware(req, _res, next) {

2

package.json
{
"name": "nestjs-pino",
"version": "2.1.0",
"version": "2.2.0-alpha.6310f7",
"description": "Pino logger for NestJS",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -6,5 +6,10 @@ import * as pino from 'pino';

export declare class PinoLogger implements PinoMethods {
/**
* root is the most root logger that can be used to change params at runtime.
* Accessible only when `useExisting` is not set to `true` in `Params`.
* Readonly, but you can change it's properties.
*/
static readonly root: pino.Logger;
private context;
private readonly contextName;
private readonly opts;
constructor({ pinoHttp, renameContext }: Params);

@@ -11,0 +16,0 @@ trace(msg: string, ...args: any[]): void;

@@ -25,2 +25,4 @@ "use strict";

outOfContext = undefined;
// @ts-ignore reset root for tests only
PinoLogger.root = undefined;
}

@@ -48,3 +50,2 @@ exports.__resetOutOfContextForTests = __resetOutOfContextForTests;

this.contextName = renameContext || 'context';
this.opts = pinoHttp;
}

@@ -51,0 +52,0 @@ trace(...args) {

@@ -409,2 +409,17 @@ <p align="center">

## Change pino params at runtime
Pino root instance with passed via module registration params creates a separate child logger for every request. This root logger params can be changed at runtime via `PinoLogger.root` property which is the pointer to logger instance. Example:
```ts
@Controller('/')
class TestController {
@Post('/change-loggin-level')
setLevel() {
PinoLogger.root.level = 'info';
return null;
}
}
```
## Migration

@@ -534,4 +549,2 @@

---
Also if you are into NestJS ecosystem you may be interested in one of my other libs:

@@ -538,0 +551,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc