gremo/nest-winston

nestLikeConsoleFormat - When the context is object it prints [[object Object]]

Sagie501 opened this issue · 3 comments

Hey!

When the context of the log is object the nestLikeConsoleFormat format print it like that:
[MyApp] Info 1.1.1990, 00:00:00 [[object Object]] Log message here! - {} +15ms

This is actually doesn't give anything.

I think that the simple solution will be to check if the context is object or string. If it is an object just stringify it.
And in addition to that we maybe need to add to the options parameter a boolean that decide if we need to show the context or not (because the object can be really huge and that will not look good).

gremo commented

Thanks @Sagie501 for helping us! I've seen also your PR. Can you try to find out what was the issue? What happened in the history? https://github.com/gremo/nest-winston/blob/master/src/winston.utilities.ts

Thanks @Sagie501 for helping us! I've seen also your PR. Can you try to find out what was the issue? What happened in the history? https://github.com/gremo/nest-winston/blob/master/src/winston.utilities.ts

I actually started using nest-winston just yesterday. Could it have never worked?

gremo commented

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 😄

Anyways, I have investigated further this issue, and I think it's not. As you can see here the context is considered to be a string. This library is aimed to be close to the NestJS default Logger implementation, so I would not support the serialization of the context property.

Feel free to reply of course!