|
74 | 74 | _logger = logging.getLogger(__name__) |
75 | 75 |
|
76 | 76 |
|
| 77 | +def _configure_cli_logging() -> None: |
| 78 | + """Route log records to stderr so stdout stays for export progress lines.""" |
| 79 | + root = logging.getLogger() |
| 80 | + if root.handlers: |
| 81 | + return |
| 82 | + logging.basicConfig( |
| 83 | + level=logging.INFO, |
| 84 | + format="%(levelname)s: %(message)s", |
| 85 | + stream=sys.stderr, |
| 86 | + ) |
| 87 | + |
| 88 | + |
77 | 89 | def _json_dump_safe(value) -> str: |
78 | 90 | """Best-effort JSON serialization for exclusion matching.""" |
79 | 91 | try: |
@@ -165,6 +177,7 @@ def parse_args(): |
165 | 177 |
|
166 | 178 |
|
167 | 179 | def main(): |
| 180 | + _configure_cli_logging() |
168 | 181 | opts = parse_args() |
169 | 182 | since = opts["since"] |
170 | 183 | out_dir = os.path.abspath(opts["out_dir"]) |
@@ -215,10 +228,9 @@ def main(): |
215 | 228 |
|
216 | 229 | with _open_global_db(workspace_path) as (global_db, global_db_path): |
217 | 230 | if global_db is None: |
218 | | - print( |
219 | | - f"Note: Cursor IDE global storage not found at {global_db_path}" |
220 | | - " — skipping IDE chats.", |
221 | | - file=sys.stderr, |
| 231 | + _logger.info( |
| 232 | + "Cursor IDE global storage not found at %s — skipping IDE chats.", |
| 233 | + global_db_path, |
222 | 234 | ) |
223 | 235 | else: |
224 | 236 | project_layouts_map = load_project_layouts_map(global_db) |
@@ -347,7 +359,12 @@ def main(): |
347 | 359 | try: |
348 | 360 | cli_projects = list_cli_projects(get_cli_chats_path()) |
349 | 361 | except Exception as e: |
350 | | - print(f"Warning: Could not enumerate CLI chats ({e}) — skipping.", file=sys.stderr) |
| 362 | + _logger.warning( |
| 363 | + "Could not enumerate CLI chats: %s (%s) — skipping", |
| 364 | + e, |
| 365 | + type(e).__name__, |
| 366 | + exc_info=True, |
| 367 | + ) |
351 | 368 | cli_projects = [] |
352 | 369 |
|
353 | 370 | for cp in cli_projects: |
@@ -378,7 +395,13 @@ def main(): |
378 | 395 | messages = traverse_blobs(session["db_path"]) |
379 | 396 | bubbles = messages_to_bubbles(messages, created_ms) |
380 | 397 | except Exception as e: |
381 | | - print(f"Warning: Could not read CLI session {session_id}: {e}", file=sys.stderr) |
| 398 | + _logger.warning( |
| 399 | + "Could not read CLI session %s: %s (%s)", |
| 400 | + session_id, |
| 401 | + e, |
| 402 | + type(e).__name__, |
| 403 | + exc_info=True, |
| 404 | + ) |
382 | 405 | continue |
383 | 406 |
|
384 | 407 | if not bubbles: |
|
0 commit comments