{"_id":"@azlibstore/nest-logger","name":"@azlibstore/nest-logger","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@azlibstore/nest-logger","version":"0.1.0","description":"Shared NestJS structured logger: an SLF4j-style @InjectLogger() decorator over pino, producing JSON output in production and pretty output in development.","author":"","license":"UNLICENSED","private":false,"main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc -p tsconfig.build.json","format":"prettier --write \"src/**/*.ts\"","lint":"eslint \"{src,test}/**/*.ts\" --fix","test":"jest","test:watch":"jest --watch","test:cov":"jest --coverage"},"peerDependencies":{"@nestjs/common":"^11.0.1","@nestjs/core":"^11.0.1","reflect-metadata":"^0.2.2"},"dependencies":{"pino":"10.3.1"},"optionalDependencies":{"pino-pretty":"13.1.3"},"devDependencies":{"@nestjs/common":"^11.0.1","@nestjs/core":"^11.0.1","@nestjs/testing":"^11.0.1","reflect-metadata":"^0.2.2","source-map-support":"^0.5.21"},"jest":{"moduleFileExtensions":["js","json","ts"],"rootDir":"src","testRegex":".*\\.spec\\.ts$","transform":{"^.+\\.(t|j)s$":"ts-jest"},"collectCoverageFrom":["**/*.(t|j)s"],"coverageDirectory":"../coverage","testEnvironment":"node"},"_id":"@azlibstore/nest-logger@0.1.0","gitHead":"56045c0019c167594b42d34bdb18940e8a614865","_nodeVersion":"20.11.1","_npmVersion":"10.2.4","dist":{"integrity":"sha512-Awao9kox3DPbQtHacBNM2COY6z++uYoKsDnpr/MZmvVs2NQU530GzzCd3rb3maz1+BhvtTIPvkrSI6SSYOuQSA==","shasum":"d07c6c8cfab4c9b8652a5454f1959ea1b088ebb4","tarball":"https://registry.npmjs.org/@azlibstore/nest-logger/-/nest-logger-0.1.0.tgz","fileCount":20,"unpackedSize":19121,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIFxchcbhafB0NIgCC7Lw9aXUnC+zdbEJQGaeoJWwv2AwAiAs7gTfVfGUdTGdJueA0Ueb77kjcS/zSTFBRdm7zNZCkw=="}]},"_npmUser":{"name":"nurlanah","email":"nurlanah@code.edu.az"},"directories":{},"maintainers":[{"name":"nurlanah","email":"nurlanah@code.edu.az"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/nest-logger_0.1.0_1788495280789_0.6904196852960658"},"_hasShrinkwrap":false}},"time":{"created":"2026-09-04T04:14:40.605Z","0.1.0":"2026-09-04T04:14:40.938Z","modified":"2026-09-04T04:14:41.203Z"},"maintainers":[{"name":"nurlanah","email":"nurlanah@code.edu.az"}],"description":"Shared NestJS structured logger: an SLF4j-style @InjectLogger() decorator over pino, producing JSON output in production and pretty output in development.","license":"UNLICENSED","readme":"# @azlibstore/nest-logger\n\nShared NestJS structured logger built on [pino](https://getpino.io), with a\nzero-boilerplate `@InjectLogger()` property decorator that automatically\ntags every log line with the class it was logged from.\n\n## Installation\n\n```bash\nnpm install @azlibstore/nest-logger\n```\n\nPeer dependencies (`@nestjs/common`, `@nestjs/core`, `reflect-metadata`)\nmust already be present in the host application. `pino-pretty` is an\noptional dependency — install it only if you plan to use\n`prettyPrint: true` (typically local development).\n\n## Setup requirement: `useDefineForClassFields`\n\nYour project's `tsconfig.json` **must** set the following in\n`compilerOptions`:\n\n```json\n{\n  \"compilerOptions\": {\n    \"useDefineForClassFields\": false\n  }\n}\n```\n\n`@InjectLogger()` works by defining a get/set accessor pair on the class\nprototype. TypeScript's default `[[Define]]` class-fields semantics\n(active once `target` is ES2022 or newer, which includes Nest 11's\ndefault starter tsconfig) make a decorated class's own field declaration\ninstall a shadowing own-property at construction time instead of going\nthrough that accessor — so without this setting, `@InjectLogger()` will\nsilently fail and the first read of the property will throw a\n`TypeError` at runtime.\n\n## Usage\n\nRegister the module with `forRoot` (or `forRootAsync` for\n`ConfigService`-sourced configuration):\n\n```typescript\nimport { Module, Injectable } from '@nestjs/common';\nimport { LoggerModule, InjectLogger, AppLogger } from '@azlibstore/nest-logger';\n\n@Injectable()\nexport class OrdersService {\n  @InjectLogger()\n  private readonly logger!: AppLogger;\n\n  placeOrder(): void {\n    this.logger.info('order placed');\n  }\n}\n\n@Module({\n  imports: [\n    LoggerModule.forRoot({\n      level: 'info',\n      prettyPrint: process.env.NODE_ENV !== 'production',\n    }),\n  ],\n  providers: [OrdersService],\n})\nexport class AppModule {}\n```\n\nEvery log line emitted through `this.logger` is automatically tagged with\n`context: 'OrdersService'` — no manual context wiring required.\n\n### Async configuration\n\n```typescript\nLoggerModule.forRootAsync({\n  imports: [ConfigModule],\n  inject: [ConfigService],\n  useFactory: (config: ConfigService) => ({\n    level: config.getOrThrow('LOG_LEVEL'),\n  }),\n});\n```\n\n### Logging errors\n\nPass an `Error` under a `meta` key named `err` to get pino's built-in\nerror serialization:\n\n```typescript\nthis.logger.error('failed to place order', { err });\n```\n\n## API\n\n- `LoggerModule.forRoot(options)` / `LoggerModule.forRootAsync(asyncOptions)`\n  — registers the module globally; both fail fast (throw synchronously, or\n  reject the module's compilation for the async form) on an invalid\n  `level`.\n- `@InjectLogger()` — property decorator; injects an `AppLogger` bound to\n  the declaring class's name.\n- `AppLogger` — `trace`/`debug`/`info`/`warn`/`error`/`fatal(message, meta?)`.\n","readmeFilename":"README.md","_rev":"1-b4e909a66690ef39daf445ddb06d5876"}