gofr-dev / gofr

An opinionated GoLang framework for accelerated microservice development. Built in support for databases and observability.
https://gofr.dev
Apache License 2.0
1.72k stars 153 forks source link

Enhance default logging to automatically log return errors #850

Closed surajit-zs closed 3 weeks ago

surajit-zs commented 1 month ago

When an error is returned, only the status code and correlation ID are logged, without the error message. This makes the logs less useful, as the reason for the error is not visible.

ref: image

To get the error message, we are manually logging the error before returning it. However, this only logs the error message without additional context like the status code and correlation ID.

ref: image

Proposed Enhancement It would be helpful if the system automatically logged errors by default, including:

Error message Status code Correlation ID

aryanmehrotra commented 1 month ago

Status code and Correlation ID are already present, we would be adding Error Message.

vikash commented 1 month ago

While we are doing this, we also need to ensure that all logs are also having the corresponding correlation ID with the line. Otherwise it will be difficult to track which error got generated during a given request lifecycle.

aditya028 commented 1 month ago

@aryanmehrotra I would like to work on this issue. please assign it to me

srijan-27 commented 1 month ago

@aditya028 - Sure, assigning this to you.

aditya028 commented 1 month ago
Screenshot 2024-07-29 at 5 07 32 PM

will it look something like this after the error log or there other changes need to be done @srijan-27 @aryanmehrotra

srijan-27 commented 1 month ago

@aditya028 - Yes, this would be the expected behaviour.

srijan-27 commented 1 month ago

@aditya028 - Are you working on it? Please let me know if you need any help.

aditya028 commented 1 month ago

@aditya028 - Are you working on it? Please let me know if you need any help.

@srijan-27 Yes i am working on it and will make the PR this weekand