Closed ochaoui closed 2 months ago
Thank you for taking the time to submit your report! From the looks of it, this could be better discussed on our Discord. If you haven't already, please join here and send a new post in the # 🐈 nestjs-help forum. Make sure to include a link to this issue, so you don't need to write it all again. We have a large community of helpful members, who will assist you in getting this to work.
Is there an existing issue for this?
Current behavior
I am struggling trying to create a loggerservice that is transient and add automatically it's context. I found this github issue that explains marely how to do it : https://github.com/nestjs/nest/issues/12565 So I tried to implement it but still get an error.
So first I created the LoggerService that implements the generic one :
I created the LoggerModule and tryed to apply what is in the github issue :
I add the module to the App Module :
With this setup, I get this error : [Nest] 14869 - 06/13/2024, 2:33:15 PM LOG [NestFactory] Starting Nest application... [Nest] 14869 - 06/13/2024, 2:33:15 PM LOG [InstanceLoader] ConfigHostModule dependencies initialized +13ms [Nest] 14869 - 06/13/2024, 2:33:15 PM LOG [InstanceLoader] ConfigModule dependencies initialized +0ms [Nest] 14869 - 06/13/2024, 2:33:15 PM LOG [InstanceLoader] LoggerModule dependencies initialized +8ms [Nest] 14869 - 06/13/2024, 2:33:15 PM ERROR [ExceptionHandler] Cannot read properties of undefined (reading 'constructor') TypeError: Cannot read properties of undefined (reading 'constructor') at InstanceWrapper.useFactory [as metatype] (/home/ochaoui/code/templates/nest-template/src/log/logger.module.ts:14:36) at Injector.instantiateClass (/home/ochaoui/code/templates/nest-template/node_modules/@nestjs/core/injector/injector.js:368:55) at callback (/home/ochaoui/code/templates/nest-template/node_modules/@nestjs/core/injector/injector.js:65:45) at Injector.resolveConstructorParams (/home/ochaoui/code/templates/nest-template/node_modules/@nestjs/core/injector/injector.js:144:24) at Injector.loadInstance (/home/ochaoui/code/templates/nest-template/node_modules/@nestjs/core/injector/injector.js:70:13)
Normally it should work as explained in the last issue
Minimum reproduction code
https://codesandbox.io/p/devbox/thirsty-wood-ynklrk?workspaceId=2a2a2b80-a9fc-4d5a-8819-b0984cffe8ed&layout=%257B%2522sidebarPanel%2522%253A%2522EXPLORER%2522%252C%2522rootPanelGroup%2522%253A%257B%2522direction%2522%253A%2522horizontal%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522id%2522%253A%2522ROOT_LAYOUT%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522clxiqf41m0007356ksjbb19yr%2522%252C%2522sizes%2522%253A%255B33.93351940179292%252C66.06648059820708%255D%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522EDITOR%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522id%2522%253A%2522clxiqf41m0002356krk3t6ywf%2522%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522SHELLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522id%2522%253A%2522clxiqf41m0004356k0ttskl49%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522DEVTOOLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522id%2522%253A%2522clxiqf41m0006356kb4bejlrz%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%252C%2522sizes%2522%253A%255B74.54371849857559%252C25.456281501424414%255D%257D%252C%2522tabbedPanels%2522%253A%257B%2522clxiqf41m0002356krk3t6ywf%2522%253A%257B%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522clxiqf41l0001356k5s70n4xf%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522FILE%2522%252C%2522filepath%2522%253A%2522%252FREADME.md%2522%252C%2522state%2522%253A%2522IDLE%2522%257D%255D%252C%2522id%2522%253A%2522clxiqf41m0002356krk3t6ywf%2522%252C%2522activeTabId%2522%253A%2522clxiqf41l0001356k5s70n4xf%2522%257D%252C%2522clxiqf41m0006356kb4bejlrz%2522%253A%257B%2522id%2522%253A%2522clxiqf41m0006356kb4bejlrz%2522%252C%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522clxiqf41m0005356kcqn95uej%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522TASK_PORT%2522%252C%2522taskId%2522%253A%2522start%2522%252C%2522port%2522%253A3000%252C%2522path%2522%253A%2522%2522%257D%255D%252C%2522activeTabId%2522%253A%2522clxiqf41m0005356kcqn95uej%2522%257D%252C%2522clxiqf41m0004356k0ttskl49%2522%253A%257B%2522id%2522%253A%2522clxiqf41m0004356k0ttskl49%2522%252C%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522clxiqf41m0003356kgeq02ryp%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522TASK_LOG%2522%252C%2522taskId%2522%253A%2522start%2522%257D%255D%252C%2522activeTabId%2522%253A%2522clxiqf41m0003356kgeq02ryp%2522%257D%257D%252C%2522showDevtools%2522%253Atrue%252C%2522showShells%2522%253Atrue%252C%2522showSidebar%2522%253Atrue%252C%2522sidebarPanelSize%2522%253A21.953125%257D
Steps to reproduce
No response
Expected behavior
It should create a logger with the context already setup
Package
Other package
No response
NestJS version
8.1.3
Packages versions
Node.js version
No response
In which operating systems have you tested?
Other
No response