How to separate print() output from multiple instances to separate tabs/sessions?

Godot Version

4.2.2

Question

If I select Debug > Run Multiple Instances > 2 and run my project, the output from print() statements from both instances go to the same Output tab.

I’m finding this confusing - is there any way to set up 2 Output tabs, in the same way that the Debugger tab has two Sessions?

As far as I know, there is no internal functionality to do that.

However, you can achieve this by simply adding a prefix of get_tree() to each print statement, as each window instance operates independently and has its own scene tree. You can also create a utility function as follows:

# I always like to give type notation
func print_local(node: Node, message: String) -> void:
    print(node.get_tree() + ": " + message)

When you print the scene tree returned by get_tree(), it will converted to a string like SceneTree#7304. Directly printing the scene tree is possible but may not be as pretty; you can explore other ways to convert the scene tree into a more readable text.