Debugging with a log file
So I went ahead and produced an Autoload scene that pops up a panel to facilitate logging of how the block code is executed.
Attached logging script:
extends Node
var thelog: PoolStringArray
func _ready():
$Popup.show()
func add(items: Array):
var txt = "%-26s" % items[0]
for i in items.size():
if i > 0:
txt += "%-12s" % items[i]
thelog.append(txt)
func output():
print(thelog.join("\n"))
func clear():
thelog.resize(0)
func save():
var fn = "../data/log.txt"
var file = File.new()
file.open(fn, File.WRITE)
file.store_string(thelog.join("\n"))
file.close()
func _on_Clear_pressed():
clear()
func _on_Print_pressed():
output()
func _on_Save_pressed():
save()
In the code header I add var tracker = true
and in various functions that I want to track, I add code such as:
if trace: Logger.add(["update_internal_bus", node.name, value, port])
Then we can obtain a log file such as this:
This lists the function name, part name, input value, and port in order of being accessed.
This extremely useful information allowed me to easily locate the point of an unexpected value being produced and then locating the source of a bug.
More Devlog entries
Most recent first
- 2021 10 02 New Release of Digital Logic Simulator
- 2021 08 28 Nested Sub Blocks
- 2021 08 26 Testing Circuit Blocks
- 2021 08 24 Bug Fixing with Blocks
- 2021 08 22 Debugging Circuit Blocks
- 2021 08 21 Circuit Blocks Update
- 2021 08 18 Circuit Blocks
- 2021 08 16 Highlighting of wires
- 2021 08 12 Adding Tutorial Content
- 2021 08 07 Numbers Scene
- 2021 08 06 Numbers Tabbed Scene
- 2021 08 04 Number Display Widget
- 2021 07 26 Logic Simulator Update
- 2021 07 24 - Launch of V1.0
- 2021 07 23 - Truth Tables
- 2021 07 22 Progress Update
- 2021 07 21 - Simple Computer Simulation
- 2021 07 16 - Community Forum
- 2021 07 15 - Community News
- 2021 07 11 - Save and Load ROM Data
- 2021 07 09 - Documentation About The Logic Simulator
- 2021 07 08 - Big Progress
- 2021 07 07 - RAM and ROM Testing Complete
- 2021 07 06 - Implementing Tests
- 2021 07 05 - Cool algorithm for binary text string
- 2021 07 04 - Debugging Complex Situations
- 2021 06 30 - End of June - Refactoring Continues
- 2021 06 29 Community
- 2021 06 28 Implementing More OOP
- 2021 06 27 Memory Parts
- 2021 06 26 Improving the Memory Manager
- 2021 06 25 Memory Data
- 2021 06 24 Memory Management
- 2021 06 23 First Devlog Entry