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

adds GD.printDebug, which outputs the .swift file name, as well as the function and line of the caller. #248

Merged
merged 3 commits into from
Nov 29, 2023

Conversation

EstevanBR
Copy link
Contributor

@EstevanBR EstevanBR commented Nov 23, 2023

This duplicates the print_debug command in Godot, which prints a message, but inserts a new line with debug info, such as the file, line, and function

Here is the example gdscript output

Hello World
   At: res://folder/node.gd:50:_ready()
  • new line below the print message
  • indented 3 spaces (we could add a param for this indentation width)
  • includes the folder/file name, relative to the res folder (we will use #fileID for this)
  • includes line number (use #line) for this
  • includes function name (use #function for this)

Here is the usage:

import SwiftGodot

@Godot
class ArrayTest: Node {
	override func _ready() {
		GD.printDebug("Hello World")
	}
}

Here is the output in the godot console:

Hello World
   At: BulletHellper/ArrayTest.swift:6 in _ready()

@EstevanBR
Copy link
Contributor Author

if we use \(#fileID):\(#line) -> SomeFolder/SomeFile.swift:102 it will print the file and line in such a way that the output can be copy pasted into Xcode's shift+cmd+O Quickly Open search to go straight to the line, but including the function name makes it more like the GDScript print_debug output.

@EstevanBR EstevanBR changed the title adds printDebug adds GD.printDebug, which outputs the .swift file name, as well as the function and line of the caller. Nov 26, 2023
@migueldeicaza
Copy link
Owner

I think it might be better to make it usable for Xcode consumption, what do you think?

@EstevanBR
Copy link
Contributor Author

EstevanBR commented Nov 28, 2023 via email

@EstevanBR
Copy link
Contributor Author

I updated it, lmk what you think.

@migueldeicaza
Copy link
Owner

Thank you!

@migueldeicaza migueldeicaza merged commit 4084ae6 into migueldeicaza:main Nov 29, 2023
1 check passed
@EstevanBR EstevanBR deleted the PrintDebug branch December 22, 2023 21:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants