Skip to content

Commit f136326

Browse files
committed
feat(text_editor.py): add logging for error handling to improve debugging
refactor(test_text_editor.py): remove debug print statements to clean up test output
1 parent 0e5c506 commit f136326

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

src/mcp_text_editor/text_editor.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
"""Core text editor functionality with file operation handling."""
22

33
import hashlib
4+
import logging
45
import os
56
from typing import Any, Dict, List, Optional, Tuple
67

78
from mcp_text_editor.models import EditPatch, FileRanges
89

10+
logger = logging.getLogger(__name__)
11+
912

1013
class TextEditor:
1114
"""Handles text file operations with security checks and conflict detection."""
@@ -426,8 +429,8 @@ async def edit_file_contents(
426429
except Exception as e:
427430
import traceback
428431

429-
print(f"Error: {str(e)}")
430-
print(f"Traceback:\n{traceback.format_exc()}")
432+
logger.error(f"Error: {str(e)}")
433+
logger.error(f"Traceback:\n{traceback.format_exc()}")
431434
return {
432435
"result": "error",
433436
"reason": "Unexpected error occurred",

tests/test_text_editor.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -500,14 +500,6 @@ async def test_edit_file_with_none_line_end(editor, tmp_path):
500500
# Get file hash
501501
content, _, _, file_hash, _, _ = await editor.read_file_contents(str(test_file))
502502

503-
# デバッグ用の出力を追加
504-
patch = {
505-
"start": 2,
506-
"end": None, # This should replace from line 2 to end
507-
"contents": "new2\nnew3\n",
508-
"range_hash": editor.calculate_hash("line2\nline3\n"),
509-
}
510-
print(f"\nDebug - Patch being sent: {patch}")
511503
# Test replacement with None as end
512504
result = await editor.edit_file_contents(
513505
str(test_file),

0 commit comments

Comments
 (0)