get_console_output
Retrieve console output from a running Godot project to monitor logs, debug issues, and filter by text or error level for focused analysis.
Instructions
Get console output from the running Godot project. Optionally filter by text or error level.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filter | No | Text filter for console output | |
| errorsOnly | No | Only show errors and warnings |
Implementation Reference
- src/server/onboarding.ts:312-341 (handler)The _get_console_output function reads the latest log file from the logs directory and returns the last 100 lines as the console output.
func _get_console_output(_params: Dictionary) -> Dictionary: \tvar log_dir := OS.get_user_data_dir() + "/logs" \tvar dir := DirAccess.open(log_dir) \tif not dir: \t\treturn {"output": [], "note": "No log directory found"} \tvar files: Array[String] = [] \tdir.list_dir_begin() \tvar file_name := dir.get_next() \twhile file_name != "": \t\tif file_name.ends_with(".log"): \t\t\tfiles.append(file_name) \t\tfile_name = dir.get_next() \tdir.list_dir_end() \tif files.is_empty(): \t\treturn {"output": [], "note": "No log files found"} \tfiles.sort() \tvar latest := files[-1] \tvar f := FileAccess.open(log_dir + "/" + latest, FileAccess.READ) \tif not f: \t\treturn {"output": [], "note": "Could not open log file"} \tvar content := f.get_as_text() \tf.close() \tvar lines := content.split("\\n") \tvar tail_count := 100 \tvar start := max(0, lines.size() - tail_count) \tvar tail: Array[String] = [] \tfor i in range(start, lines.size()): \t\tif lines[i].strip_edges() != "": \t\t\ttail.append(lines[i]) \treturn {"output": tail, "file": latest}