mcp-code-indexer 1.2.4__py3-none-any.whl → 1.4.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,8 +18,8 @@ def setup_logging(
18
18
  log_level: str = "INFO",
19
19
  log_file: Optional[Path] = None,
20
20
  enable_file_logging: bool = False,
21
- max_bytes: int = 10 * 1024 * 1024, # 10MB
22
- backup_count: int = 5
21
+ max_bytes: int = 50 * 1024 * 1024, # 50MB
22
+ backup_count: int = 2
23
23
  ) -> logging.Logger:
24
24
  """
25
25
  Set up comprehensive logging configuration.
@@ -58,12 +58,20 @@ def setup_logging(
58
58
  log_file.parent.mkdir(parents=True, exist_ok=True)
59
59
 
60
60
  # Rotating file handler
61
- file_handler = logging.handlers.RotatingFileHandler(
62
- log_file,
63
- maxBytes=max_bytes,
64
- backupCount=backup_count,
65
- encoding='utf-8'
66
- )
61
+ if max_bytes > 0:
62
+ file_handler = logging.handlers.RotatingFileHandler(
63
+ log_file,
64
+ maxBytes=max_bytes,
65
+ backupCount=backup_count,
66
+ encoding='utf-8'
67
+ )
68
+ else:
69
+ # No size limit - use regular FileHandler
70
+ file_handler = logging.FileHandler(
71
+ log_file,
72
+ mode='a',
73
+ encoding='utf-8'
74
+ )
67
75
  file_handler.setLevel(logging.DEBUG) # File gets all levels
68
76
  file_handler.setFormatter(structured_formatter)
69
77
 
@@ -107,6 +115,66 @@ def get_logger(name: str) -> logging.Logger:
107
115
  return logging.getLogger(name)
108
116
 
109
117
 
118
+ def setup_command_logger(
119
+ command_name: str,
120
+ cache_dir: Path,
121
+ log_level: str = "DEBUG"
122
+ ) -> logging.Logger:
123
+ """
124
+ Set up a dedicated logger for specific commands (runcommand, githook).
125
+
126
+ Args:
127
+ command_name: Name of the command (e.g., 'runcommand', 'githook')
128
+ cache_dir: Cache directory path
129
+ log_level: Logging level
130
+
131
+ Returns:
132
+ Configured logger for the command
133
+ """
134
+ logger_name = f"mcp_code_indexer.{command_name}"
135
+ logger = logging.getLogger(logger_name)
136
+
137
+ # Don't propagate to parent loggers to avoid duplicate console output
138
+ logger.propagate = False
139
+ logger.setLevel(getattr(logging, log_level.upper()))
140
+
141
+ # Clear existing handlers
142
+ logger.handlers.clear()
143
+
144
+ # Create log file path
145
+ log_file = cache_dir / f"{command_name}.log"
146
+
147
+ try:
148
+ # Ensure cache directory exists
149
+ cache_dir.mkdir(parents=True, exist_ok=True)
150
+
151
+ # File handler with 50MB limit
152
+ file_handler = logging.handlers.RotatingFileHandler(
153
+ log_file,
154
+ maxBytes=50 * 1024 * 1024, # 50MB
155
+ backupCount=2,
156
+ encoding='utf-8'
157
+ )
158
+ file_handler.setLevel(logging.DEBUG)
159
+
160
+ # Use structured formatter
161
+ structured_formatter = StructuredFormatter()
162
+ file_handler.setFormatter(structured_formatter)
163
+
164
+ logger.addHandler(file_handler)
165
+
166
+ logger.info(f"=== {command_name.upper()} SESSION STARTED ===")
167
+
168
+ except (OSError, PermissionError) as e:
169
+ # Fallback to console logging
170
+ console_handler = logging.StreamHandler(sys.stderr)
171
+ console_handler.setFormatter(StructuredFormatter())
172
+ logger.addHandler(console_handler)
173
+ logger.warning(f"Failed to set up {command_name} file logging: {e}")
174
+
175
+ return logger
176
+
177
+
110
178
  def log_performance_metrics(
111
179
  logger: logging.Logger,
112
180
  operation: str,