fixed camera and sword animation issue and upgraded to Godot 4.6
This commit is contained in:
@@ -11,15 +11,6 @@ enum TYPE {
|
||||
|
||||
const GdUnitTools := preload("res://addons/gdUnit4/src/core/GdUnitTools.gd")
|
||||
|
||||
const PATTERN_SCRIPT_ERROR := "USER SCRIPT ERROR:"
|
||||
const PATTERN_PUSH_ERROR := "USER ERROR:"
|
||||
const PATTERN_PUSH_WARNING := "USER WARNING:"
|
||||
# With Godot 4.4 the pattern has changed
|
||||
const PATTERN_4x4_SCRIPT_ERROR := "SCRIPT ERROR:"
|
||||
const PATTERN_4x4_PUSH_ERROR := "ERROR:"
|
||||
const PATTERN_4x4_PUSH_WARNING := "WARNING:"
|
||||
|
||||
static var _regex_parse_error_line_number: RegEx
|
||||
|
||||
var _type: TYPE
|
||||
var _line: int
|
||||
@@ -34,39 +25,17 @@ func _init(type: TYPE, line: int, message: String, details: String) -> void:
|
||||
_details = details
|
||||
|
||||
|
||||
static func is_godot4x4() -> bool:
|
||||
return Engine.get_version_info().hex >= 0x40400
|
||||
func _to_string() -> String:
|
||||
return _message
|
||||
|
||||
|
||||
static func extract_push_warning(records: PackedStringArray, index: int) -> ErrorLogEntry:
|
||||
var pattern := PATTERN_4x4_PUSH_WARNING if is_godot4x4() else PATTERN_PUSH_WARNING
|
||||
return _extract(records, index, TYPE.PUSH_WARNING, pattern)
|
||||
static func of_push_warning(file: String, line: int, message: String, stack_trace: PackedStringArray) -> ErrorLogEntry:
|
||||
return ErrorLogEntry.new(TYPE.PUSH_WARNING, line, message, "\n".join(stack_trace))
|
||||
|
||||
|
||||
static func extract_push_error(records: PackedStringArray, index: int) -> ErrorLogEntry:
|
||||
var pattern := PATTERN_4x4_PUSH_ERROR if is_godot4x4() else PATTERN_PUSH_ERROR
|
||||
return _extract(records, index, TYPE.PUSH_ERROR, pattern)
|
||||
static func of_push_error(file: String, line: int, message: String, stack_trace: PackedStringArray) -> ErrorLogEntry:
|
||||
return ErrorLogEntry.new(TYPE.PUSH_ERROR, line, message, "\n".join(stack_trace))
|
||||
|
||||
|
||||
static func extract_error(records: PackedStringArray, index: int) -> ErrorLogEntry:
|
||||
var pattern := PATTERN_4x4_SCRIPT_ERROR if is_godot4x4() else PATTERN_SCRIPT_ERROR
|
||||
return _extract(records, index, TYPE.SCRIPT_ERROR, pattern)
|
||||
|
||||
|
||||
static func _extract(records: PackedStringArray, index: int, type: TYPE, pattern: String) -> ErrorLogEntry:
|
||||
var message := records[index]
|
||||
if message.begins_with(pattern):
|
||||
var error := message.replace(pattern, "").strip_edges()
|
||||
var details := records[index+1].strip_edges()
|
||||
var line := _parse_error_line_number(details)
|
||||
return ErrorLogEntry.new(type, line, error, details)
|
||||
return null
|
||||
|
||||
|
||||
static func _parse_error_line_number(record: String) -> int:
|
||||
if _regex_parse_error_line_number == null:
|
||||
_regex_parse_error_line_number = GdUnitTools.to_regex("at: .*res://.*:(\\d+)")
|
||||
var matches := _regex_parse_error_line_number.search(record)
|
||||
if matches != null:
|
||||
return matches.get_string(1).to_int()
|
||||
return -1
|
||||
static func of_script_error(file: String, line: int, message: String, stack_trace: PackedStringArray) -> ErrorLogEntry:
|
||||
return ErrorLogEntry.new(TYPE.SCRIPT_ERROR, line, message, "\n".join(stack_trace))
|
||||
|
||||
@@ -1 +1 @@
|
||||
uid://8kjgr8gyjg5f
|
||||
uid://bes35loejld0m
|
||||
|
||||
@@ -1 +1 @@
|
||||
uid://gq08i83yup2g
|
||||
uid://cdnhapffl440n
|
||||
|
||||
70
addons/gdUnit4/src/monitor/GdUnitOrphanNodeInfo.gd
Normal file
70
addons/gdUnit4/src/monitor/GdUnitOrphanNodeInfo.gd
Normal file
@@ -0,0 +1,70 @@
|
||||
class_name GdUnitOrphanNodeInfo
|
||||
extends RefCounted
|
||||
|
||||
enum GdUnitOrphanType {
|
||||
member,
|
||||
variable,
|
||||
unknown
|
||||
}
|
||||
|
||||
|
||||
var _id: int
|
||||
var _orphan_type: GdUnitOrphanType
|
||||
var _type: String
|
||||
var _name: String
|
||||
var _script_ref: String
|
||||
var _func_ref: String
|
||||
var _next: GdUnitOrphanNodeInfo
|
||||
|
||||
const text_color := Color.ANTIQUE_WHITE
|
||||
const function_color := Color.SKY_BLUE
|
||||
const member_variable_color := Color.SALMON
|
||||
const engine_type_color := Color.LIGHT_GREEN
|
||||
const script_path_color := Color.CORNFLOWER_BLUE
|
||||
|
||||
|
||||
func _init(orphan_type: GdUnitOrphanType, id: int, type: String, name: String, script_ref: String, func_ref: String = "") -> void:
|
||||
_orphan_type = orphan_type
|
||||
_id = id
|
||||
_type = type
|
||||
_name = name
|
||||
_script_ref = script_ref
|
||||
_func_ref = func_ref
|
||||
|
||||
|
||||
func as_trace(info: GdUnitOrphanNodeInfo, show_orphan_id := true) -> String:
|
||||
var trace := ""
|
||||
if show_orphan_id:
|
||||
trace += "• <%s> Id:%s\n" % [
|
||||
_colored(info._type, engine_type_color),
|
||||
_colored(info._id, engine_type_color)]
|
||||
match info._orphan_type:
|
||||
GdUnitOrphanType.member:
|
||||
return trace + " at %s script: %s" % [
|
||||
_colored(info._name, member_variable_color),
|
||||
_colored(info._script_ref, script_path_color)
|
||||
] + sub_info(info._next)
|
||||
GdUnitOrphanType.variable:
|
||||
return trace + " at %s script: %s.%s()" % [
|
||||
_colored(info._name, member_variable_color),
|
||||
_colored(info._script_ref, script_path_color),
|
||||
_colored(info._func_ref, function_color),
|
||||
]
|
||||
GdUnitOrphanType.unknown:
|
||||
return trace + " %s" % [
|
||||
_colored(info._name, member_variable_color)
|
||||
]
|
||||
|
||||
_:
|
||||
return trace + " No details available"
|
||||
|
||||
|
||||
func sub_info(next: GdUnitOrphanNodeInfo) -> String:
|
||||
if next == null:
|
||||
return ""
|
||||
|
||||
return "\n" + as_trace(next, false)
|
||||
|
||||
|
||||
static func _colored(value: Variant, color: Color) -> String:
|
||||
return "[color=%s]%s[/color]" % [color.to_html(), value]
|
||||
1
addons/gdUnit4/src/monitor/GdUnitOrphanNodeInfo.gd.uid
Normal file
1
addons/gdUnit4/src/monitor/GdUnitOrphanNodeInfo.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://d4gm05v0lyn5p
|
||||
@@ -1,27 +1,221 @@
|
||||
class_name GdUnitOrphanNodesMonitor
|
||||
extends GdUnitMonitor
|
||||
|
||||
var _initial_count := 0
|
||||
var _orphan_count := 0
|
||||
const excluded_frame_files: PackedStringArray = [
|
||||
"GdUnitOrphanNodesMonitor",
|
||||
"GdUnitExecutionContext",
|
||||
"_TestCase",
|
||||
"IGdUnitExecutionStage",
|
||||
"GdUnitTestCaseSingleTestStage",
|
||||
"GdUnitTestCaseSingleExecutionStage",
|
||||
"GdUnitTestCaseExecutionStage",
|
||||
"GdUnitTestSuiteExecutionStage",
|
||||
"GdUnitTestSuiteExecutor"
|
||||
]
|
||||
|
||||
var _child_monitors: Array[GdUnitOrphanNodesMonitor] = []
|
||||
var _orphan_detection_enabled :bool
|
||||
var _initial_orphans: Array[int] = []
|
||||
var _orphan_ids_at_start: Array[int] = []
|
||||
var _orphan_ids_at_stop: Array[int] = []
|
||||
var _collected_orphan_infos: Array[GdUnitOrphanNodeInfo] = []
|
||||
|
||||
|
||||
func _init(name :String = "") -> void:
|
||||
func _init(name: String) -> void:
|
||||
super("OrphanNodesMonitor:" + name)
|
||||
_orphan_detection_enabled = GdUnitSettings.is_verbose_orphans()
|
||||
_initial_orphans = _get_orphan_node_ids()
|
||||
|
||||
|
||||
func add_child_monitor(monitor: GdUnitOrphanNodesMonitor) -> void:
|
||||
if not _orphan_detection_enabled:
|
||||
return
|
||||
_child_monitors.append(monitor)
|
||||
|
||||
|
||||
func start() -> void:
|
||||
_initial_count = _orphans()
|
||||
if not _orphan_detection_enabled:
|
||||
return
|
||||
_collected_orphan_infos.clear()
|
||||
# Collect current orphan id's to be filtered out at `stop`
|
||||
_orphan_ids_at_start = _get_orphan_node_ids()
|
||||
|
||||
|
||||
func stop() -> void:
|
||||
_orphan_count = max(0, _orphans() - _initial_count)
|
||||
if not _orphan_detection_enabled:
|
||||
return
|
||||
# Collect only new detected orphan id's, we want only to collect orphans between start and stop time
|
||||
_orphan_ids_at_stop = _get_orphan_node_ids().filter(func(element: int) -> bool:
|
||||
# Excluding sub monitores orphans
|
||||
if _collect_child_orphan_ids().has(element):
|
||||
return false
|
||||
# Excluding orphans at start
|
||||
return not _orphan_ids_at_start.has(element) and not _initial_orphans.has(element)
|
||||
)
|
||||
|
||||
|
||||
func _orphans() -> int:
|
||||
return Performance.get_monitor(Performance.OBJECT_ORPHAN_NODE_COUNT) as int
|
||||
func _collect_child_orphan_ids() -> Array[int]:
|
||||
var collected_ids: Array[int] = []
|
||||
for child_monitor in _child_monitors:
|
||||
collected_ids.append_array(child_monitor._orphan_ids_at_stop)
|
||||
collected_ids.append_array(child_monitor._collect_child_orphan_ids())
|
||||
return collected_ids
|
||||
|
||||
|
||||
func orphan_nodes() -> int:
|
||||
return _orphan_count if _orphan_detection_enabled else 0
|
||||
func detected_orphans() -> Array[GdUnitOrphanNodeInfo]:
|
||||
if not _orphan_detection_enabled:
|
||||
return []
|
||||
return _collected_orphan_infos.filter(func(info: GdUnitOrphanNodeInfo) -> bool:
|
||||
return info._id in _orphan_ids_at_stop
|
||||
)
|
||||
|
||||
|
||||
func orphans_count() -> int:
|
||||
if not _orphan_detection_enabled:
|
||||
return 0
|
||||
return _orphan_ids_at_stop.size()
|
||||
|
||||
|
||||
func collect() -> void:
|
||||
if not _orphan_detection_enabled:
|
||||
return
|
||||
for orphan_id in _get_orphan_node_ids():
|
||||
var orphan_to_find := instance_from_id(orphan_id)
|
||||
_collect_orphan_info(orphan_to_find)
|
||||
|
||||
|
||||
func _collect_orphan_info(orphan_to_find: Object) -> void:
|
||||
if orphan_to_find == null:
|
||||
return
|
||||
|
||||
var orphan_node := _find_orphan_on_backtraces(orphan_to_find)
|
||||
if orphan_node:
|
||||
_collected_orphan_infos.append(orphan_node)
|
||||
return
|
||||
|
||||
if Engine.has_meta("GdUnitSceneRunner"):
|
||||
var current_scene_runner:GdUnitSceneRunner = Engine.get_meta("GdUnitSceneRunner")
|
||||
if is_instance_valid(current_scene_runner):
|
||||
orphan_node = _find_orphan_at_node(orphan_to_find, current_scene_runner.scene())
|
||||
if orphan_node:
|
||||
_collected_orphan_infos.append(orphan_node)
|
||||
return
|
||||
|
||||
# not able to find the orphan node via backtrace loaded nodeds
|
||||
var message := "No details found. Verify called functions manually."
|
||||
if not EngineDebugger.is_active():
|
||||
message = "No details available. [color=yellow]Run tests in debug mode to collect details.[/color]"
|
||||
|
||||
_collected_orphan_infos.append(GdUnitOrphanNodeInfo.new(
|
||||
GdUnitOrphanNodeInfo.GdUnitOrphanType.unknown,
|
||||
orphan_to_find.get_instance_id(),
|
||||
orphan_to_find.get_class(),
|
||||
message,
|
||||
""))
|
||||
|
||||
|
||||
func _find_orphan_at_node(orphan_to_find: Object, node: Node) -> GdUnitOrphanNodeInfo:
|
||||
var script: Script = node.get_script()
|
||||
if script is not GDScript:
|
||||
return null
|
||||
|
||||
# First search over all properties
|
||||
for property in script.get_script_property_list():
|
||||
var property_name: String = property["name"]
|
||||
var property_type: int = property["type"]
|
||||
# Is untyped or type object
|
||||
if property_type in [TYPE_NIL, TYPE_OBJECT]:
|
||||
var property_instance: Variant = node.get(property_name)
|
||||
@warning_ignore("unsafe_cast")
|
||||
var property_as_node := property_instance as Node if property_instance != null else null
|
||||
if property_as_node == null:
|
||||
continue
|
||||
if property_as_node == orphan_to_find:
|
||||
return GdUnitOrphanNodeInfo.new(
|
||||
GdUnitOrphanNodeInfo.GdUnitOrphanType.member,
|
||||
orphan_to_find.get_instance_id(),
|
||||
orphan_to_find.get_class(),
|
||||
property_name,
|
||||
script.resource_path)
|
||||
|
||||
# Search on node childs
|
||||
var orphan_node_info := _find_orphan_at_node(orphan_to_find, property_as_node)
|
||||
if orphan_node_info:
|
||||
orphan_node_info._next = GdUnitOrphanNodeInfo.new(
|
||||
GdUnitOrphanNodeInfo.GdUnitOrphanType.member,
|
||||
orphan_to_find.get_instance_id(),
|
||||
orphan_to_find.get_class(),
|
||||
property_name,
|
||||
script.resource_path)
|
||||
return orphan_node_info
|
||||
|
||||
# Second over all children
|
||||
for child_node in node.get_children():
|
||||
var orphan_node_info := _find_orphan_at_node(orphan_to_find, child_node)
|
||||
if orphan_node_info:
|
||||
return orphan_node_info
|
||||
return null
|
||||
|
||||
|
||||
func _is_frame_file_excluded(frame_file: String) -> bool:
|
||||
for file in excluded_frame_files:
|
||||
if frame_file.contains(file):
|
||||
return true
|
||||
return false
|
||||
|
||||
|
||||
func _find_orphan_on_backtraces(orphan_to_find: Object) -> GdUnitOrphanNodeInfo:
|
||||
for script_backtrace in Engine.capture_script_backtraces(true):
|
||||
for frame in script_backtrace.get_frame_count():
|
||||
var frame_file := script_backtrace.get_frame_file(frame)
|
||||
if _is_frame_file_excluded(frame_file):
|
||||
continue
|
||||
|
||||
# Scan function variables
|
||||
for l_index in script_backtrace.get_local_variable_count(frame):
|
||||
var variable_instance: Variant = script_backtrace.get_local_variable_value(frame, l_index)
|
||||
var variable_name := script_backtrace.get_local_variable_name(frame, l_index)
|
||||
if typeof(variable_instance) in [TYPE_NIL, TYPE_OBJECT]:
|
||||
@warning_ignore("unsafe_cast")
|
||||
var node := variable_instance as Node
|
||||
if node == null:
|
||||
continue
|
||||
if variable_instance == orphan_to_find:
|
||||
return GdUnitOrphanNodeInfo.new(
|
||||
GdUnitOrphanNodeInfo.GdUnitOrphanType.variable,
|
||||
orphan_to_find.get_instance_id(),
|
||||
orphan_to_find.get_class(),
|
||||
variable_name,
|
||||
script_backtrace.get_frame_file(frame),
|
||||
script_backtrace.get_frame_function(frame))
|
||||
else:
|
||||
var orphan_node_info := _find_orphan_at_node(orphan_to_find, node)
|
||||
if orphan_node_info:
|
||||
return orphan_node_info
|
||||
|
||||
# Scan class members
|
||||
for m_index in script_backtrace.get_member_variable_count(frame):
|
||||
var member_instance: Variant = script_backtrace.get_member_variable_value(frame, m_index)
|
||||
var member_name := script_backtrace.get_member_variable_name(frame, m_index)
|
||||
if typeof(member_instance) in [TYPE_NIL, TYPE_OBJECT]:
|
||||
@warning_ignore("unsafe_cast")
|
||||
var node := member_instance as Node
|
||||
if node == null:
|
||||
continue
|
||||
if member_instance == orphan_to_find:
|
||||
return GdUnitOrphanNodeInfo.new(
|
||||
GdUnitOrphanNodeInfo.GdUnitOrphanType.member,
|
||||
orphan_to_find.get_instance_id(),
|
||||
orphan_to_find.get_class(),
|
||||
member_name,
|
||||
script_backtrace.get_frame_file(frame))
|
||||
else:
|
||||
var orphan_node_info := _find_orphan_at_node(orphan_to_find, node)
|
||||
if orphan_node_info:
|
||||
return orphan_node_info
|
||||
return null
|
||||
|
||||
|
||||
static func _get_orphan_node_ids() -> Array[int]:
|
||||
@warning_ignore("unsafe_property_access", "unsafe_method_access")
|
||||
return Engine.get_main_loop().root.get_orphan_node_ids()
|
||||
|
||||
@@ -1 +1 @@
|
||||
uid://cufv71udymwm5
|
||||
uid://drhj71ijt4x5u
|
||||
|
||||
@@ -1,94 +1,103 @@
|
||||
class_name GodotGdErrorMonitor
|
||||
extends GdUnitMonitor
|
||||
|
||||
var _godot_log_file: String
|
||||
var _eof: int
|
||||
var _report_enabled := false
|
||||
var _entries: Array[ErrorLogEntry] = []
|
||||
var _logger: Logger
|
||||
|
||||
|
||||
class GdUnitLogger extends Logger:
|
||||
var _entries: Array[ErrorLogEntry] = []
|
||||
var _line_number: int
|
||||
|
||||
|
||||
func entries() -> Array[ErrorLogEntry]:
|
||||
return _entries
|
||||
|
||||
|
||||
func _log_error(function: String, file: String, line: int, message: String, rationale: String, editor_notify: bool, error_type: int, script_backtraces: Array[ScriptBacktrace]) -> void:
|
||||
match error_type:
|
||||
ErrorType.ERROR_TYPE_WARNING:
|
||||
var stack_trace := _build_stack_trace(script_backtraces)
|
||||
_entries.append(ErrorLogEntry.of_push_warning(file, _line_number, message, stack_trace))
|
||||
|
||||
ErrorType.ERROR_TYPE_ERROR:
|
||||
var stack_trace := _build_stack_trace(script_backtraces)
|
||||
_entries.append(ErrorLogEntry.of_push_error(file, _line_number, message, stack_trace))
|
||||
|
||||
ErrorType.ERROR_TYPE_SCRIPT:
|
||||
var stack_trace := _build_stack_trace(script_backtraces)
|
||||
_entries.append(ErrorLogEntry.of_script_error(file, _line_number, message, stack_trace))
|
||||
|
||||
ErrorType.ERROR_TYPE_SHADER:
|
||||
pass
|
||||
_:
|
||||
prints("Unknwon log type", message)
|
||||
|
||||
func _log_message(message: String, error: bool) -> void:
|
||||
pass
|
||||
|
||||
func _build_stack_trace(script_backtraces: Array[ScriptBacktrace]) -> PackedStringArray:
|
||||
for sb in script_backtraces:
|
||||
for frame in sb.get_frame_count():
|
||||
# Find start of test stack
|
||||
if sb.get_frame_file(frame) == "res://addons/gdUnit4/src/core/_TestCase.gd":
|
||||
var stack_trace := PackedStringArray()
|
||||
for test_case_frame in range(0, frame):
|
||||
_line_number = sb.get_frame_line(test_case_frame)
|
||||
stack_trace.append(" at %s:%s" % [sb.get_frame_file(test_case_frame), sb.get_frame_line(test_case_frame)])
|
||||
return stack_trace
|
||||
# if no stack trace collected, we in an await function call
|
||||
var sb := script_backtraces[0]
|
||||
return [" at %s:%s" % [sb.get_frame_file(0), sb.get_frame_line(0)]]
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
super("GodotGdErrorMonitor")
|
||||
_godot_log_file = GdUnitSettings.get_log_path()
|
||||
super("GdUnitLoggerMonitor")
|
||||
_report_enabled = _is_reporting_enabled()
|
||||
_logger = GdUnitLogger.new()
|
||||
OS.add_logger(_logger)
|
||||
|
||||
|
||||
func _notification(what: int) -> void:
|
||||
if what == NOTIFICATION_PREDELETE:
|
||||
if _logger:
|
||||
OS.remove_logger(_logger)
|
||||
|
||||
|
||||
func start() -> void:
|
||||
var file := FileAccess.open(_godot_log_file, FileAccess.READ)
|
||||
if file:
|
||||
file.seek_end(0)
|
||||
_eof = file.get_length()
|
||||
clear_logs()
|
||||
|
||||
|
||||
func stop() -> void:
|
||||
pass
|
||||
|
||||
|
||||
func log_entries() -> Array[ErrorLogEntry]:
|
||||
return _logger.entries()
|
||||
|
||||
|
||||
func to_reports() -> Array[GdUnitReport]:
|
||||
var reports_: Array[GdUnitReport] = []
|
||||
if _report_enabled:
|
||||
reports_.assign(_entries.map(_to_report))
|
||||
_entries.clear()
|
||||
reports_.assign(log_entries().map(_to_report))
|
||||
|
||||
return reports_
|
||||
|
||||
|
||||
static func _to_report(errorLog: ErrorLogEntry) -> GdUnitReport:
|
||||
var failure := "%s\n\t%s\n%s %s" % [
|
||||
var failure := """
|
||||
%s
|
||||
%s %s
|
||||
%s""".dedent().trim_prefix("\n") % [
|
||||
GdAssertMessages._error("Godot Runtime Error !"),
|
||||
GdAssertMessages._colored_value(errorLog._details),
|
||||
GdAssertMessages._error("Error:"),
|
||||
GdAssertMessages._colored_value(errorLog._message)]
|
||||
GdAssertMessages._colored_value(errorLog._message),
|
||||
GdAssertMessages._colored(errorLog._details, GdAssertMessages.VALUE_COLOR)]
|
||||
return GdUnitReport.new().create(GdUnitReport.ABORT, errorLog._line, failure)
|
||||
|
||||
|
||||
func scan(force_collect_reports := false) -> Array[ErrorLogEntry]:
|
||||
await (Engine.get_main_loop() as SceneTree).process_frame
|
||||
await (Engine.get_main_loop() as SceneTree).physics_frame
|
||||
_entries.append_array(_collect_log_entries(force_collect_reports))
|
||||
return _entries
|
||||
|
||||
|
||||
func erase_log_entry(entry: ErrorLogEntry) -> void:
|
||||
_entries.erase(entry)
|
||||
|
||||
|
||||
func collect_full_logs() -> PackedStringArray:
|
||||
await (Engine.get_main_loop() as SceneTree).process_frame
|
||||
await (Engine.get_main_loop() as SceneTree).physics_frame
|
||||
|
||||
var file := FileAccess.open(_godot_log_file, FileAccess.READ)
|
||||
file.seek(_eof)
|
||||
var records := PackedStringArray()
|
||||
while not file.eof_reached():
|
||||
@warning_ignore("return_value_discarded")
|
||||
records.append(file.get_line())
|
||||
|
||||
return records
|
||||
|
||||
|
||||
func _collect_log_entries(force_collect_reports: bool) -> Array[ErrorLogEntry]:
|
||||
var file := FileAccess.open(_godot_log_file, FileAccess.READ)
|
||||
if not file:
|
||||
# Log file might not be available.
|
||||
return []
|
||||
file.seek(_eof)
|
||||
var records := PackedStringArray()
|
||||
while not file.eof_reached():
|
||||
@warning_ignore("return_value_discarded")
|
||||
records.append(file.get_line())
|
||||
file.seek_end(0)
|
||||
_eof = file.get_length()
|
||||
var log_entries: Array[ErrorLogEntry]= []
|
||||
var is_report_errors := force_collect_reports or _is_report_push_errors()
|
||||
var is_report_script_errors := force_collect_reports or _is_report_script_errors()
|
||||
for index in records.size():
|
||||
if force_collect_reports:
|
||||
log_entries.append(ErrorLogEntry.extract_push_warning(records, index))
|
||||
if is_report_errors:
|
||||
log_entries.append(ErrorLogEntry.extract_push_error(records, index))
|
||||
if is_report_script_errors:
|
||||
log_entries.append(ErrorLogEntry.extract_error(records, index))
|
||||
return log_entries.filter(func(value: ErrorLogEntry) -> bool: return value != null )
|
||||
func clear_logs() -> void:
|
||||
log_entries().clear()
|
||||
|
||||
|
||||
func _is_reporting_enabled() -> bool:
|
||||
|
||||
@@ -1 +1 @@
|
||||
uid://de86ibngfhvf5
|
||||
uid://c1ygt0mxmk741
|
||||
|
||||
Reference in New Issue
Block a user