From b9ca08304f93f2fb02c41843d5d41fa2a5fa8730 Mon Sep 17 00:00:00 2001 From: Mikael Hermansson Date: Wed, 17 Sep 2025 14:22:34 +0200 Subject: [PATCH] Mention importance of thread-safety in `Logger` example --- tutorials/scripting/logging.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tutorials/scripting/logging.rst b/tutorials/scripting/logging.rst index ee6a1ecd3..a51cdbaee 100644 --- a/tutorials/scripting/logging.rst +++ b/tutorials/scripting/logging.rst @@ -225,6 +225,8 @@ Here is a minimal working example of a custom logger, with the script added as a 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()`. + # Note that this method will be called from threads other than the main thread, possibly at the same + # time, so you will need to have some kind of thread-safety as part of it, like a Mutex. pass func _log_error( @@ -239,6 +241,8 @@ Here is a minimal working example of a custom logger, with the script added as a ) -> void: # Do something with the error. The error text is in `rationale`. # See the Logger class reference for details on other parameters. + # Note that this method will be called from threads other than the main thread, possibly at the same + # time, so you will need to have some kind of thread-safety as part of it, like a Mutex. pass # Use `_init()` to initialize the logger as early as possible, which ensures that messages