-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Context is lost when logging errors #473
Comments
Your logger.error takes three arguments You should have something like |
I'm sorry for the very late response, I'm quite busy recently with my personal and working life. I'll try to follow more this library that, honestly, went so far and has been used by many. Didn't expected that 😄 @faithfulojebiyi you seems more on the point than me, can i close this? |
@gremo we could update the docs to help others out. if I also notice any other irregularities I'd let you know. let's be sure it fixed @floretan-ebot7 issue then you can close it |
@faithfulojebiyi provide a PR to clarify the docs then? |
@gremo PR done |
But he passed in the |
@xunziheng is correct. This is a bug. The cause of this is that the NestJS This is supported by the type definition ( In the case that |
I should note that this is all caused by the fact that In fact, the current behavior is quite defensible given that in most languages, if you have multiple optional parameters, it is the last one that gets omitted first - this would result in The problem is that |
You can check the docs https://github.com/gremo/nest-winston#logger-methods usage is explained there |
Opened a PR with a fix: #513 Since things were already ambiguous, the fix has its downsides. Feel free to accept or reject. |
@faithfulojebiyi I have absolutely read the documentation if it wasn't already clear. The issue isn't the documentation, it is that when you implement a logger that works with Nest, you need to follow Nest's rules. And you're not. It is totally legitimate usage to do that the OP has done, and nothing the documentation says will change that! To be perfectly honest, I spent a good deal of time writing up a carefully considered explanation of what is wrong here and why it is wrong, and it is concerning to receive what basically amounts to a pre-recorded reply of "please read the documentation." |
@abrindam I think we should go for the Nest-like behavior, that is following that rules:
... then:
Feel free to upgrade #513 to reflect this changes, thanks! |
I can confirm that @ChrisiPK's pull request fixed this for me! It works fine now in NestJS 9.3.1 🥳 |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
This issue was closed because it has been stalled for 7 days with no activity. |
While debugging while certain log entries were missing the
context
property, I found out that it seems that the context is lost when calling the.error()
method. Here is some example code:Which gives this output with the json formatter:
As you can see, the first log entry is fine. The second log entry with the error is putting the context in the stack property.
With the same code, the default Nest logger keeps the context in the right place:
The text was updated successfully, but these errors were encountered: