Unity MCP 없이 IDE에서 유니티 에러 로그 확인하는 법.
요새 AI Assistant를 활용한 개발이 주류가 되면서,
유니티도 Unity-MCP 라는 mcp가 생겼습니다.
바로 claude나 cursor의 에이전트를 unity 에디터와 연결해주는 mcp인데요, read_console이라는 메소드를 호출하면 실시간 에러 로그를 불러올 수도 있습니다.
하지만 이 기능이 잘 작동하지 않을 때가 있습니다.
그럴 때에는 agent에게 간단히 로그를 볼 수 있는 python script를 실행해서 그 결과를 참조하라고 할 수가 있습니다.
그래서 만들어보았습니다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
```python
# unity_log_agent.py
import time
from pathlib import Path
def tail_log_file(log_path: Path, keywords=None, tail_count=100):
if keywords is None:
keywords = ["error", "exception", "fail", "warning"]
if not log_path.exists():
print("❌ Editor.log 파일이 없습니다.")
return
with open(log_path, "r", encoding="utf-8", errors="ignore") as f:
lines = f.readlines()
# 필터링된 최근 로그
filtered = [line.strip() for line in lines if any(k in line.lower() for k in keywords)]
tail = filtered[-tail_count:]
print("\n📦 최근 Unity 로그 (필터링된 메시지들):\n")
for line in tail:
print(line)
# 현재 이 스크립트가 있는 폴더에 저장도 가능. file() 함수 사용
out_path = Path(__file__).parent / "FilteredUnityErrors.log.txt"
with open(out_path, "w", encoding="utf-8") as f:
f.write("\n".join(tail))
print(f"\n✅ 저장 완료: {out_path}")
if __name__ == "__main__":
log_path = Path.home() / "AppData" / "Local" / "Unity" / "Editor" / "Editor.log"
print("🕵️ Unity 로그 분석 에이전트 시작 중...")
time.sleep(1)
tail_log_file(log_path)
```
실행하면 이런 식으로 결과가 나옵니다.
이런 간단한 메소드는 굳이 mcp로 새로 만들 필요 없이 스크립트로 만들어놓는 것도 편한 것 같습니다.
이 기사는 저작권자의 CC BY 4.0 라이센스를 따릅니다.

