StagLogger¶
Inherits: Logger
Simple Logger wrapper that allows for script error detection.
Description¶
Allows logging with log levels, and can optionally include Engine logs and error detection.
The logger supports additional customization, such as console colors and log levels log_level_console.
If the logger is registered with the engine via OS.add_logger(), pushed errors and warnings will automatically be written to the buffer (if one exists).
var logger := StagLogger.new()
# Customize logger as desired...
logger.log_level_console = StagLogger.LogLevel.LLDebug
logger.log_level_buffer = StagLogger.LogLevel.LLInfo
logger.color_warn = Color.YELLOW
logger.flush_interval = 50
# ...
logger.create_buffer(false) # Optionally create a temp file for writing to
OS.add_logger(logger) # Optionally register logger with Engine for error catching
# Do some logging.
logger.debug("debug message")
logger.info("info message")
logger.warn("warning message")
logger.error("error message")
# Clean up the logger.
logger.close()
OS.remove_logger(logger) # Unregister logger from engine
Properties¶
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
||
|
||
|
|
|
|
|
|
|
|
Methods¶
void |
_log_error(function: |
void |
_log_message(message: |
void |
debug(message: |
void |
info(message: |
void |
warn(message: |
void |
error(message: |
void |
_write_console(message: |
void |
_write_buffer(message: |
Error |
create_buffer(keep: |
void |
set_buffer(new_buffer: |
void |
flush() |
void |
close() |
Signals¶
event_warning(message: String) 🔗
Emitted when Godot Engine passes a warning.
event_error(message: String) 🔗
Emitted when Godot Engine passes an error.
event_error_script(message: String) 🔗
Emitted when Godot Engine passes a script error.
event_error_shader(message: String) 🔗
Emitted when Godot Engine passes a shader error.
Enumerations¶
enum LogLevel: 🔗
LogLevel LLDebug = 0
Show all messages.
LogLevel LLInfo = 1
Show informational messages, warnings, and errors.
LogLevel LLWarn = 2
Only show warnings and errors.
LogLevel LLError = 3
Only show errors.
Property Descriptions¶
Color color_debug = Color(0.74509805, 0.74509805, 0.74509805, 1) 🔗
Console coloration for debug logs.
Color color_info = Color(1, 1, 1, 1) 🔗
Console coloration for information logs.
Color color_warn = Color(1, 0.64705884, 0, 1) 🔗
Console coloration for warning logs.
Color color_error = Color(1, 0, 0, 1) 🔗
Console coloration for error logs.
String error_string = "{file}@{line} (type {error_type}) -> {function}: {code}{rationale}{backtrace}" 🔗
Error string for automatic error logging (i.e. script or shader errors).
bool error_backtraces = true 🔗
Whether to include backtraces in automatic error logs.
LogLevel log_level_buffer = 0 🔗
What logs are actually written to the buffer.
LogLevel log_level_console = 0 🔗
What logs are actually written to the console.
FileAccess buffer 🔗
Temporary log file where buffer writes are written to. I would do this as a memory file, but it’s not yet implemented.
int flush_interval = 50 🔗
How many messages can be passed before a flush occurs automatically.
Flushes write buffer data to the logfile, which can be expensive if done frequently. However, if data is not flushed, it may be missing from the file if the engine crashes.
In normal conditions, the file should be flushed automatically when dereferencing the logger, or if you call close().
bool flush_after_error = true 🔗
Immediately flush after writing an error, regardless of how many lines were written.
int _messages_until_flush = 0 🔗
There is currently no description for this property. Please help us by contributing one!
Method Descriptions¶
void _log_error(function: String, file: String, line: int, code: String, rationale: String, editor_notify: bool, error_type: int, script_backtraces: Array[ScriptBacktrace]) 🔗
There is currently no description for this method. Please help us by contributing one!
void _log_message(message: String, is_error: bool) 🔗
There is currently no description for this method. Please help us by contributing one!
void debug(message: String) 🔗
Logs a message with the “debug” log level.
void info(message: String) 🔗
Logs a message with the “info” log level.
void warn(message: String, use_push: bool = false) 🔗
Logs a message with the “warn” log level.
If use_push is true, it will use @GlobalScope.push_warning() instead. This will be logged to the buffer with a stacktrace if the logger is registered with the Engine.
void error(message: String, use_push: bool = false) 🔗
Logs a message with the “error” log level.
If use_push is true, it will use @GlobalScope.push_error() instead. This will be logged to the buffer with a stacktrace if the logger is registered with the Engine.
void _write_console(message: String, color: Color) 🔗
There is currently no description for this method. Please help us by contributing one!
void _write_buffer(message: String, is_error: bool = false) 🔗
There is currently no description for this method. Please help us by contributing one!
Error create_buffer(keep: bool = false, prefix: String = “log”) 🔗
Initializes a temporary file for writing to. Closes the existing buffer if there is one. You can choose to provide your own file with set_buffer().
keep sets whether cause the file persists in your temp directory after closing. prefix sets the prefix of the file for organizational purposes.
Returns OK if the buffer was successfully opened, or a filesystem Error otherwise.
void set_buffer(new_buffer: FileAccess) 🔗
Sets the file for writing to. Closes the existing buffer if there is one.
void flush() 🔗
Flushes the buffer, writing directly to the logfile.
void close() 🔗
Flushes and closes the logfile.