-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Add logging documentation #11266
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
Merged
Merged
Add logging documentation #11266
+309
−43
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7a1c1d3
to
7af417b
Compare
Calinou
commented
Sep 9, 2025
Comment on lines
+199
to
+248
.. code-block:: gdscript | ||
extends Node | ||
class CustomLogger extends Logger: | ||
# Note that this method is not called for messages that use | ||
# `push_error()` and `push_warning()`, even though these are printed to stderr. | ||
func _log_message(message: String, error: bool) -> void: | ||
# Do something with `message`. | ||
# `error` is `true` for messages printed to the standard error stream (stderr) with `print_error()`. | ||
pass | ||
func _log_error( | ||
function: String, | ||
file: String, | ||
line: int, | ||
code: String, | ||
rationale: String, | ||
editor_notify: bool, | ||
error_type: int, | ||
script_backtraces: Array[ScriptBacktrace] | ||
) -> void: | ||
# Do something with the error. The error text is in `rationale`. | ||
# See the Logger class reference for details on other parameters. | ||
pass | ||
# Use `_init()` to initialize the logger as early as possible, which ensures that messages | ||
# printed early are taken into account. However, even when using `_init()`, the engine's own | ||
# initialization messages are not accessible. | ||
func _init() -> void: | ||
OS.add_logger(CustomLogger.new()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that I've decided to add type hints for this code sample, as it's arguably easier to understand with type hints present (and this documentation is fairly advanced).
521ada7
to
2053bd7
Compare
Cykyrios
reviewed
Sep 9, 2025
3e99080
to
73e4e02
Compare
mhilbrunner
approved these changes
Sep 10, 2025
AThousandShips
approved these changes
Sep 10, 2025
This also covers how to create custom loggers. - Remove notice on Windows 10 requirement for `print_rich()` in Output panel, since Godot requires Windows 10 as of 4.5.
73e4e02
to
7b98025
Compare
Thanks! Merged. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area:manual
Issues and PRs related to the Manual/Tutorials section of the documentation
cherrypick:4.5
content:new page
Issues and PRs related to creation of new documentation pages for new or undocumented features
linked demo pr
Documentation PRs that are tied to a demo repository PR
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This also covers how to create custom loggers.
Logger
and ability to print and log script backtraces godot#91006.