bithavoc / express-winston

express.js middleware for winstonjs
https://www.npmjs.com/package/express-winston
MIT License
797 stars 187 forks source link

make "middlewareError" more meaningful in the console output #134

Closed melalj closed 7 years ago

melalj commented 7 years ago

Where there's an error within express, it outputs by default middlewareError as error message with a massive stacktrace.

It's pretty hard to spot right away what's wrong. I tried to customize the output with the option in errorLogger: msg: "{{stack[0]}} but it doesn't seems to do anything.

rosston commented 7 years ago

It sounds like your problem is more with the stack trace than express-winston's output. Am I understanding your issue correctly?

As you found, there is currently no way to customize the logged output of errors (other than the msg, which is pretty trivial). I personally haven't found much need for that scenario, but I'm open to ideas/PRs.

melalj commented 7 years ago

It was more to quickly see on the console what is the error message instead of middlewareError, I found a workaround by setting: msg: '{{err.message}}' for errorLogger

rosston commented 7 years ago

Ah, excellent! Glad you found something that does what you need. Should this issue be closed then, or is there something outstanding?

melalj commented 7 years ago

Since there's a way to show the error message instead of middlewareError, we can say that this ticket is solved ;) Maybe someone would stumble upon this issue and customise the output. (Maybe you should improve the readme to state that err can be used for msg in errorLogger in addition of req and res) Thanks btw for developing this tool :)

rosston commented 7 years ago

No problem! I updated the readme to include err as an example in the error logger's msg option (https://github.com/bithavoc/express-winston/commit/d488e28)