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.

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.

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

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, 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)

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:

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")

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.