Skip to content
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

Add stack trace into make logs if DEBUG True #994

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,54 @@ You can also [join our Discord channel #development](https://discord.gg/JuhHdHTt

![-----------------------------------------------------](https://raw.githubusercontent.com/andreasbm/readme/master/assets/lines/aqua.png)

### Submitting issues

You can submit issues related to this project, but you should do it in a way that helps developers to resolve it as quickly as possible.

For that, you need to add as much valuable information as possible.

You can have this valuable information by following these steps:

- Go to the root of the git cloned project
- Edit `web/entrypoint.sh` and add `export DEBUG=1` at the top
This should give you this result

```python
#!/bin/bash

export DEBUG=1

python3 manage.py migrate
python3 manage.py runserver 0.0.0.0:8000

exec "$@"
```
- Restart the web container: `docker-compose restart web`
- To deactivate, set **DEBUG** to **0** and restart the web container again

Then, with **DEBUG** set to **1**, in the `make logs` output you could see the full stack trace to debug reNgine.

Example with the tool arsenal version check API bug.

```
web_1 | File "/usr/local/lib/python3.10/dist-packages/celery/app/task.py", line 411, in __call__
web_1 | return self.run(*args, **kwargs)
web_1 | TypeError: run_command() got an unexpected keyword argument 'echo'
```
Now you know the real error is `TypeError: run_command() got an unexpected keyword argument 'echo'`

And you can post the full stack trace to your newly created issue to help developers to track the root cause of the bug and correct the bug easily

**Activating debug like this also give you the full stack trace in the browser** instead of an error 500 without any details.
So don't forget to open the developer console and check for any XHR request with error 500.
If there's any, check the response of this request to get your detailed error.

<img src="https://user-images.githubusercontent.com/1230954/276260955-ed1e1168-7c8f-43a3-b54d-b6285d52b771.png">

Happy issuing ;)

![-----------------------------------------------------](https://raw.githubusercontent.com/andreasbm/readme/master/assets/lines/aqua.png)

### First-time Open Source contributors

Please note that reNgine is beginner friendly. If you have never done open-source before, we encourage you to do so. **We will be happy and proud of your first PR ever.**
Expand Down
10 changes: 10 additions & 0 deletions web/reNgine/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@
'version': 1,
'disable_existing_loggers': True,
'handlers': {
'file': {
'level': 'ERROR',
'class': 'logging.FileHandler',
'filename': 'errors.log',
},
'null': {
'class': 'logging.NullHandler'
},
Expand Down Expand Up @@ -240,6 +245,11 @@
}
},
'loggers': {
'django': {
'handlers': ['file'],
'level': 'ERROR' if DEBUG else 'CRITICAL',
'propagate': True,
},
'': {
'handlers': ['brief'],
'level': 'DEBUG' if DEBUG else 'INFO',
Expand Down