> For the complete documentation index, see [llms.txt](https://stevetautonico.gitbook.io/tarbs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://stevetautonico.gitbook.io/tarbs/documentation/7.-debugging.md).

# 11. Debugging

## Debugging

### 11.1 Summary

T.A.R.B.S. engine comes with some useful debugging tools. Enabling the debugger helps to see whats going on under the hood. Debugging enables you to find out, specifically, what is causing an issue in your code. **Debugging is enabled by updating the value of a var.**

```python
TARBSengine.debug = True
# Enables debugging mode
```

When `TARBSengine.debug` is set to true, it enables the `TARBSengine.debugout` function to execute. `debugout` prints what happened when a function executed. For example, if you call `Player.editinv` with debugging enabled, it will output `Debugger: item given {item} x {amount}`. The debugger told us what's going on. This allows us to figure out what is causing the issue. If you multiple functions, and something is working improperly, debugging mode can let you know, specifically, which function is causing a problem.

### 11.2 Logging

When executing a program made with T.A.R.B.S., a log file is now generated. The log file keeps track of every debug output and when they occurred. This can help in the debugging stage of development to view re-occurring errors, especially if the errors are well handled and don't exit the program when encountered. Logging is preformed automatically, as long as it is enabled. Logging can be enabled by setting the `TARBSengine.enable_logging` var to true and generating the log.

```python
TARBSengine.enable_logging = True
TARBSengine.genlog()
# Enables logging
```

While logging is enabled, every event that takes place will be added to a timestamped log file. This can help keep track of errors and what could be causing the error. Example log:

```
DEBUG:root: Run from 11:13:53
DEBUG:root: 11:13:53: Damage done: 8
DEBUG:root: 11:13:53: Enemy HP: 3
DEBUG:root: 11:13:53: Enemy: Damage done: 7
DEBUG:root: 11:13:53: Enemy player HP: 13
DEBUG:root: 11:13:53: Damage done: 10
DEBUG:root: 11:13:53: Enemy HP: -7
DEBUG:root: 11:13:53: Debugging: Opponent deleted
DEBUG:root: 11:13:53: The Princess: Thank you for saving me
DEBUG:root: 11:13:53: The Princess: You look hurt, here is a magic potion to heal you
DEBUG:root: 11:13:53: Debugger: item given: Magic Health Potion x 1
DEBUG:root: 11:13:53: 5 health restored, current health: 18
```

### 11.3 Examples

```python
player.remove_item(super_shield)
# Debugger: removed super_shield from player

player.use_potion(hp_potion)
# 5 health restored, current health: 17

player.say("This is some text")
#Steve: This is some text
```

### 11.4 Reporting Functions

The reporting functions are used to send reports and feature requests to me through GitHub directly from your code or terminal. For most of the functions, a GitHub token is required. This token allows you to log into GitHub through the API. To generate a personal access token, go [here](https://github.com/settings/tokens), click generate new token, add a token description to remember what it is for, select the public repo scope (this permission only grants access to public repos, such as adding issues and comments to public repos, and starring them) ([you can read more about personal access tokens here](https://developer.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/))

#### Reporting functions:

* issue(token, title, body)
  * `token`: Access token for account
  * `title`: The title of the issue report
  * `body`: The body/description for the issue report
* feature(token, title, body)
  * `token`: Access token for account
  * `title`: The title of the feature request
  * `body`: The body/description for the feature request

#### Usage example:

```python
issue("[YOUR TOKEN HERE]", "Bug happened", "There is an issue with this feature that needs to be fixed")
feature("[YOUR TOKEN HERE]", "New items", "I want this feature to be added")
```

![](https://1009768164-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LNKzTeYD55MXoCDVZcl%2F-LTh6wWAgkM02rVPC3W7%2F-LTh73d0FdTG1j-z3uTc%2FCapture.PNG?alt=media\&token=51aea6a1-5f20-4fa7-a15b-3b3c553d8f47)

![](https://1009768164-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LNKzTeYD55MXoCDVZcl%2F-LTh6wWAgkM02rVPC3W7%2F-LTh76EH-AKY3ZbnHcHU%2FCapture2.PNG?alt=media\&token=1eeb59cf-5368-498d-baa0-2b9b902d5125)

![](https://1009768164-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LNKzTeYD55MXoCDVZcl%2F-LTh6wWAgkM02rVPC3W7%2F-LTh784zqVVEpOaMgGh9%2FCapture3.PNG?alt=media\&token=02dd57a9-c155-410e-af67-5f997d251d2f)

{% hint style="danger" %}
To ensure that your feature can be accommodated or your bug report is handled, please describe your issue or request in detail to the best of your ability.
{% endhint %}
