output_panel.rst 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. .. _doc_output_panel:
  2. Output panel
  3. ============
  4. The output panel is found at the bottom of the screen. Click on **Output** to open it.
  5. .. image:: img/overview_output.webp
  6. The output panel provides several features to make viewing text printed by the
  7. project (and editor) easier.
  8. .. note::
  9. The output panel automatically opens when running a project by default.
  10. You can control this behavior by changing the **Run > Bottom Panel > Action on Play**
  11. editor setting.
  12. Message categories
  13. ------------------
  14. Four message categories are available:
  15. - **Log:** Standard messages printed by the project. Displayed in white or black
  16. (depending on the editor theme).
  17. - **Error:** Messages printed by the project or editor that indicate a failure
  18. of some kind. Displayed in red.
  19. - **Warning:** Messages printed by the project or editor that report important
  20. information, but do not indicate a failure. Displayed in yellow.
  21. - **Editor:** Messages printed by the editor, typically intended to be traces of
  22. undo/redo actions. Displayed in gray.
  23. Filtering messages
  24. ------------------
  25. By clicking on the buttons on the right, you can hide certain message categories.
  26. This can make it easier to find specific messages you're looking for.
  27. You can also filter messages by their text content using the **Filter Messages** box
  28. at the bottom of the Output panel.
  29. Clearing messages
  30. -----------------
  31. When running the project, existing messages are automatically cleared by default. This
  32. is controlled by the **Run > Output > Always Clear Output on Play** editor setting.
  33. Additionally, you can manually clear messages by clicking the "cleaning brush" icon
  34. in the top-right corner of the Output panel.
  35. .. _doc_output_panel_printing_messages:
  36. Printing messages
  37. -----------------
  38. Several methods are available to print messages:
  39. - :ref:`print() <class_@GlobalScope_method_print>`: Prints a message.
  40. This method accepts multiple arguments which are concatenated together upon printing.
  41. This method has variants that separate arguments with tabs and spaces respectively:
  42. :ref:`printt() <class_@GlobalScope_method_printt>` and :ref:`prints() <class_@GlobalScope_method_prints>`.
  43. - :ref:`print_rich() <class_@GlobalScope_method_print_rich>`: Same as ``print()``,
  44. but BBCode can be used to format the text that is printed (see below).
  45. - :ref:`push_error() <class_@GlobalScope_method_push_error>`: Prints an error message.
  46. When an error is printed in a running project, it's displayed in the **Debugger > Errors**
  47. tab instead.
  48. - :ref:`push_warning() <class_@GlobalScope_method_push_warning>`: Prints a warning message.
  49. When a warning is printed in a running project, it's displayed in the **Debugger > Errors**
  50. tab instead.
  51. For more complex use cases, these can be used:
  52. - :ref:`print_verbose() <class_@GlobalScope_method_print_verbose>`: Same as ``print()``,
  53. but only prints when verbose mode is enabled in the Project Settings
  54. or the project is run with the ``--verbose`` command line argument.
  55. - :ref:`printerr() <class_@GlobalScope_method_printerr>`: Same as ``print()``,
  56. but prints to the standard error stream instead of the standard output string.
  57. ``push_error()`` should be preferred in most cases.
  58. - :ref:`printraw() <class_@GlobalScope_method_printraw>`: Same as ``print()``,
  59. but prints without a blank line at the end. This is the only method
  60. that does **not** print to the editor Output panel.
  61. It prints to the standard output stream *only*, which means it's still included
  62. in file logging.
  63. - :ref:`print_stack() <class_@GDScript_method_print_stack>`: Print a stack trace
  64. from the current location. Only supported when running from the editor,
  65. or when the project is exported in debug mode.
  66. - :ref:`print_tree() <class_Node_method_print_tree>`: Prints the scene tree
  67. relative to the current node. Useful for debugging node structures created at runtime.
  68. - :ref:`print_tree_pretty() <class_Node_method_print_tree_pretty>`: Same as
  69. ``print_tree()``, but with Unicode characters for a more tree-like appearance. This relies on
  70. `box-drawing characters <https://en.wikipedia.org/wiki/Box-drawing_characters>`__,
  71. so it may not render correctly with all fonts.
  72. To get more advanced formatting capabilities, consider using
  73. :ref:`doc_gdscript_printf` along with the above printing functions.
  74. .. seealso::
  75. The engine's logging facilities are covered in the :ref:`logging <doc_logging>`
  76. documentation.
  77. .. _doc_output_panel_printing_rich_text:
  78. Printing rich text
  79. ~~~~~~~~~~~~~~~~~~
  80. Using :ref:`print_rich() <class_@GlobalScope_method_print_rich>`, you can print
  81. rich text to the editor Output panel and standard output (visible when the user
  82. runs the project from a terminal). This works by converting the BBCode to
  83. `ANSI escape codes <https://en.wikipedia.org/wiki/ANSI_escape_code>`__ that the
  84. terminal understands.
  85. In the editor output, all BBCode tags are recognized as usual. In the terminal
  86. output, only a subset of BBCode tags will work, as documented in the linked
  87. ``print_rich()`` method description above. In the terminal, the colors will look
  88. different depending on the user's theme, while colors in the editor will use the
  89. same colors as they would in the project.
  90. .. note::
  91. ANSI escape code support varies across terminal emulators. The exact colors
  92. displayed in terminal output also depend on the terminal theme chosen by the user.