nestjs-pino
Advanced tools
Comparing version 3.3.0 to 3.4.0
import { LoggerService } from '@nestjs/common'; | ||
import { Params } from './params'; | ||
import { PinoLogger } from './PinoLogger'; | ||
import { Params } from './params'; | ||
export declare class Logger implements LoggerService { | ||
@@ -13,2 +13,3 @@ protected readonly logger: PinoLogger; | ||
error(message: any, ...optionalParams: any[]): void; | ||
fatal(message: any, ...optionalParams: any[]): void; | ||
private call; | ||
@@ -15,0 +16,0 @@ /** |
@@ -16,5 +16,6 @@ "use strict"; | ||
exports.Logger = void 0; | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
const common_1 = require("@nestjs/common"); | ||
const params_1 = require("./params"); | ||
const PinoLogger_1 = require("./PinoLogger"); | ||
const params_1 = require("./params"); | ||
let Logger = exports.Logger = class Logger { | ||
@@ -40,2 +41,5 @@ constructor(logger, { renameContext }) { | ||
} | ||
fatal(message, ...optionalParams) { | ||
this.call('fatal', message, ...optionalParams); | ||
} | ||
call(level, message, ...optionalParams) { | ||
@@ -42,0 +46,0 @@ const objArg = {}; |
@@ -10,2 +10,3 @@ "use strict"; | ||
exports.LoggerErrorInterceptor = void 0; | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
const common_1 = require("@nestjs/common"); | ||
@@ -12,0 +13,0 @@ const rxjs_1 = require("rxjs"); |
@@ -17,8 +17,9 @@ "use strict"; | ||
exports.LoggerModule = void 0; | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
const common_1 = require("@nestjs/common"); | ||
const pino_http_1 = require("pino-http"); | ||
const InjectPinoLogger_1 = require("./InjectPinoLogger"); | ||
const Logger_1 = require("./Logger"); | ||
const params_1 = require("./params"); | ||
const PinoLogger_1 = require("./PinoLogger"); | ||
const InjectPinoLogger_1 = require("./InjectPinoLogger"); | ||
const storage_1 = require("./storage"); | ||
@@ -101,2 +102,3 @@ const DEFAULT_ROUTES = [{ path: '*', method: common_1.RequestMethod.ALL }]; | ||
} | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore: run requires arguments for next but should not because it can | ||
@@ -103,0 +105,0 @@ // be called without arguments |
{ | ||
"name": "nestjs-pino", | ||
"version": "3.3.0", | ||
"version": "3.4.0", | ||
"description": "Pino logger for NestJS", | ||
@@ -8,4 +8,4 @@ "main": "index.js", | ||
"scripts": { | ||
"test": "jest --verbose -i --detectOpenHandles", | ||
"lint": "eslint \"{src,__tests__}/**/*.ts\" --fix", | ||
"test": "jest --verbose -i --detectOpenHandles --forceExit", | ||
"lint": "tsc --noemit && eslint \"{src,__tests__}/**/*.ts\" --fix", | ||
"prebuild": "rimraf dist", | ||
@@ -19,3 +19,5 @@ "build": "tsc -p tsconfig.build.json", | ||
"files": [ | ||
"*.{js,d.ts}" | ||
"*.{js,d.ts}", | ||
"!jest.config.js", | ||
"!.eslintrc.js" | ||
], | ||
@@ -37,3 +39,3 @@ "engineStrict": true, | ||
], | ||
"author": "Oleg Repin <iamolegga@gmail.com> (http://github.com/iamolegga)", | ||
"author": "iamolegga <iamolegga@gmail.com> (http://github.com/iamolegga)", | ||
"license": "MIT", | ||
@@ -45,23 +47,23 @@ "bugs": { | ||
"devDependencies": { | ||
"@nestjs/common": "^10.0.0", | ||
"@nestjs/core": "^10.0.0", | ||
"@nestjs/platform-express": "^10.0.0", | ||
"@nestjs/platform-fastify": "^10.0.0", | ||
"@nestjs/testing": "^10.0.0", | ||
"@nestjs/common": "^10.2.0", | ||
"@nestjs/core": "^10.2.0", | ||
"@nestjs/platform-express": "^10.2.0", | ||
"@nestjs/platform-fastify": "^10.2.0", | ||
"@nestjs/testing": "^10.2.0", | ||
"@types/express": "^4.17.17", | ||
"@types/jest": "^29.5.2", | ||
"@types/jest": "^29.5.3", | ||
"@types/memorystream": "^0.3.1", | ||
"@types/node": "^20.3.1", | ||
"@types/node": "^20.5.1", | ||
"@types/supertest": "^2.0.12", | ||
"@typescript-eslint/eslint-plugin": "^5.59.11", | ||
"@typescript-eslint/parser": "^5.59.11", | ||
"eslint": "^8.42.0", | ||
"eslint-config-prettier": "^8.8.0", | ||
"eslint-plugin-import": "^2.27.5", | ||
"eslint-plugin-prettier": "^4.2.1", | ||
"jest": "29.5.0", | ||
"@typescript-eslint/eslint-plugin": "^6.4.0", | ||
"@typescript-eslint/parser": "^6.4.0", | ||
"eslint": "^8.47.0", | ||
"eslint-config-prettier": "^9.0.0", | ||
"eslint-plugin-import": "^2.28.1", | ||
"eslint-plugin-prettier": "^5.0.0", | ||
"jest": "29.6.2", | ||
"memorystream": "^0.3.1", | ||
"pino": "^8.14.1", | ||
"pino-http": "^8.3.3", | ||
"prettier": "^2.8.8", | ||
"pino": "^8.15.0", | ||
"pino-http": "^8.4.0", | ||
"prettier": "^3.0.2", | ||
"reflect-metadata": "^0.1.13", | ||
@@ -71,24 +73,7 @@ "rimraf": "^5.0.1", | ||
"supertest": "^6.3.3", | ||
"ts-jest": "^29.1.0", | ||
"ts-loader": "^9.4.3", | ||
"ts-jest": "^29.1.1", | ||
"ts-loader": "^9.4.4", | ||
"ts-node": "^10.9.1", | ||
"tslint": "^6.0.0", | ||
"typescript": "^5.1.3" | ||
"typescript": "^5.1.6" | ||
}, | ||
"jest": { | ||
"moduleFileExtensions": [ | ||
"js", | ||
"ts" | ||
], | ||
"testRegex": ".spec.ts$", | ||
"transform": { | ||
"^.+\\.(t|j)s$": "ts-jest" | ||
}, | ||
"collectCoverage": true, | ||
"coverageDirectory": "./coverage", | ||
"collectCoverageFrom": [ | ||
"src/**/*.ts" | ||
], | ||
"testEnvironment": "node" | ||
}, | ||
"peerDependencies": { | ||
@@ -95,0 +80,0 @@ "@nestjs/common": "^8.0.0 || ^9.0.0 || ^10.0.0", |
@@ -0,4 +1,4 @@ | ||
import { MiddlewareConfigProxy, ModuleMetadata } from '@nestjs/common/interfaces'; | ||
import { Logger, DestinationStream } from 'pino'; | ||
import { Options } from 'pino-http'; | ||
import { Logger, DestinationStream } from 'pino'; | ||
import { MiddlewareConfigProxy, ModuleMetadata } from '@nestjs/common/interfaces'; | ||
export type PassedLogger = { | ||
@@ -5,0 +5,0 @@ logger: Logger; |
@@ -29,2 +29,3 @@ import pino from 'pino'; | ||
constructor({ pinoHttp, renameContext }: Params); | ||
get logger(): pino.Logger; | ||
trace(msg: string, ...args: any[]): void; | ||
@@ -43,6 +44,5 @@ trace(obj: unknown, msg?: string, ...args: any[]): void; | ||
setContext(value: string): void; | ||
assign(fields: pino.Bindings): void; | ||
protected call(method: pino.Level, ...args: Parameters<LoggerFn>): void; | ||
get logger(): pino.Logger; | ||
assign(fields: pino.Bindings): void; | ||
} | ||
export {}; |
@@ -17,2 +17,3 @@ "use strict"; | ||
exports.PinoLogger = exports.__resetOutOfContextForTests = void 0; | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
/* eslint-disable @typescript-eslint/ban-types */ | ||
@@ -26,2 +27,3 @@ const common_1 = require("@nestjs/common"); | ||
outOfContext = undefined; | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore reset root for tests only | ||
@@ -52,2 +54,8 @@ PinoLogger.root = undefined; | ||
} | ||
get logger() { | ||
var _a; | ||
// outOfContext is always set in runtime before starts using | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
return ((_a = storage_1.storage.getStore()) === null || _a === void 0 ? void 0 : _a.logger) || outOfContext; | ||
} | ||
trace(...args) { | ||
@@ -74,2 +82,9 @@ this.call('trace', ...args); | ||
} | ||
assign(fields) { | ||
const store = storage_1.storage.getStore(); | ||
if (!store) { | ||
throw new Error(`${PinoLogger_1.name}: unable to assign extra fields out of request scope`); | ||
} | ||
store.logger = store.logger.child(fields); | ||
} | ||
call(method, ...args) { | ||
@@ -96,18 +111,6 @@ if (this.context) { | ||
} | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore args are union of tuple types | ||
this.logger[method](...args); | ||
} | ||
get logger() { | ||
var _a; | ||
// outOfContext is always set in runtime before starts using | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
return ((_a = storage_1.storage.getStore()) === null || _a === void 0 ? void 0 : _a.logger) || outOfContext; | ||
} | ||
assign(fields) { | ||
const store = storage_1.storage.getStore(); | ||
if (!store) { | ||
throw new Error(`${PinoLogger_1.name}: unable to assign extra fields out of request scope`); | ||
} | ||
store.logger = store.logger.child(fields); | ||
} | ||
}; | ||
@@ -114,0 +117,0 @@ exports.PinoLogger = PinoLogger = PinoLogger_1 = __decorate([ |
@@ -19,3 +19,8 @@ <p align="center"> | ||
</a> | ||
<img alt="GitHub branch checks state" src="https://badgen.net/github/checks/iamolegga/nestjs-pino"> | ||
<a href="https://www.npmjs.com/package/nestjs-pino"> | ||
<img alt="npm" src="https://img.shields.io/npm/dm/nestjs-pino" /> | ||
</a> | ||
<a href="https://github.com/iamolegga/nestjs-pino/actions"> | ||
<img alt="GitHub branch checks state" src="https://badgen.net/github/checks/iamolegga/nestjs-pino"> | ||
</a> | ||
<a href="https://codeclimate.com/github/iamolegga/nestjs-pino/test_coverage"> | ||
@@ -25,6 +30,8 @@ <img src="https://api.codeclimate.com/v1/badges/2821150bb93506cb66fc/test_coverage" /> | ||
<a href="https://snyk.io/test/github/iamolegga/nestjs-pino"> | ||
<img alt="Snyk Vulnerabilities for npm package" src="https://img.shields.io/snyk/vulnerabilities/npm/nestjs-pino" /> | ||
<img alt="Known Vulnerabilities" src="https://snyk.io/test/github/iamolegga/nestjs-pino/badge.svg" /> | ||
</a> | ||
<img alt="Libraries.io" src="https://img.shields.io/librariesio/release/npm/nestjs-pino"> | ||
<img alt="Dependabot" src="https://badgen.net/dependabot/iamolegga/nestjs-pino/?icon=dependabot"> | ||
<a href="https://libraries.io/npm/nestjs-pino"> | ||
<img alt="Libraries.io" src="https://img.shields.io/librariesio/release/npm/nestjs-pino"> | ||
</a> | ||
<img alt="Dependabot" src="https://badgen.net/github/dependabot/iamolegga/nestjs-pino"> | ||
<img alt="Supported platforms: Express & Fastify" src="https://img.shields.io/badge/platforms-Express%20%26%20Fastify-green" /> | ||
@@ -567,9 +574,9 @@ </p> | ||
| `pino` method | `PinoLogger` method | NestJS built-in `Logger` method | | ||
| ------------- | ------------------- | --------------- | | ||
| **trace** | **trace** | **verbose** | | ||
| debug | debug | debug | | ||
| **info** | **info** | **log** | | ||
| warn | warn | warn | | ||
| error | error | error | | ||
| **fatal** | **fatal** | - | | ||
| ------------- | ------------------- | --------------------------------| | ||
| **trace** | **trace** | **verbose** | | ||
| debug | debug | debug | | ||
| **info** | **info** | **log** | | ||
| warn | warn | warn | | ||
| error | error | error | | ||
| fatal | fatal | fatal (since nestjs@10.2) | | ||
@@ -576,0 +583,0 @@ --- |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
56988
29
600
606