Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

Logger

Eredita: RefCounted < Object

Logger personalizzato per ricevere messaggi dal flusso interno di errori/avvisi.

Descrizione

Logger personalizzato per ricevere messaggi dal flusso interno di errori/avvisi. I logger si registrano tramite OS.add_logger().

Tutorial

Metodi

void

_log_error(function: String, file: String, line: int, code: String, rationale: String, editor_notify: bool, error_type: int, script_backtraces: Array[ScriptBacktrace]) virtual

void

_log_message(message: String, error: bool) virtual


Enumerazioni

enum ErrorType: 🔗

ErrorType ERROR_TYPE_ERROR = 0

Il messaggio ricevuto è un errore.

ErrorType ERROR_TYPE_WARNING = 1

Il messaggio ricevuto è un avviso.

ErrorType ERROR_TYPE_SCRIPT = 2

Il messaggio ricevuto è un errore di script.

ErrorType ERROR_TYPE_SHADER = 3

Il messaggio ricevuto è un errore di shader.


Descrizioni dei metodi

void _log_error(function: String, file: String, line: int, code: String, rationale: String, editor_notify: bool, error_type: int, script_backtraces: Array[ScriptBacktrace]) virtual 🔗

Chiamato quando un errore viene registrato. L'errore fornisce la funzione (function), il file (file) e la riga (line) da cui ha avuto origine, nonché il codice (code) che ha generato l'errore o una motivazione (rationale).

Il tipo di errore, fornito da error_type, è descritto nell'enumerazione ErrorType.

Inoltre, script_backtraces fornisce backtrace per ciascuno dei linguaggi di script. Normalmente, questi conterranno stack frame solo nelle build dell'editor e nelle build di debug. Per abilitarli anche per le build di rilascio, è necessario abilitare ProjectSettings.debug/settings/gdscript/always_track_call_stacks.

Attenzione: Questa funzione si può chiamare da più thread diversi, quindi potrebbe essere necessario eseguire i propri blocchi.

Nota: script_backtraces non conterrà alcuna variabile catturata, a causa del suo costo proibitivo. Per ottenerle, sarà necessario catturare personalmente i backtrace, dall'interno dei metodi virtuali del Logger, attraverso Engine.capture_script_backtraces().

Nota: Registrare gli errori da questo metodo tramite funzioni come @GlobalScope.push_error() o @GlobalScope.push_warning() non è supportata, in quanto potrebbe causare una ricorsione infinita. Questi errori appariranno solo nell'output della console.


void _log_message(message: String, error: bool) virtual 🔗

Called when a message is logged. If error is true, then this message was meant to be sent to stderr.

Warning: 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 in your implementation of it, like a Mutex.

Note: Logging another message from this method using functions like @GlobalScope.print() is not supported, as it could cause infinite recursion. These messages will only show up in the console output.