Skip to content

Commit 33d0478

Browse files
committed
fix: update export.py to use logger instead of print.
1 parent 9cda07b commit 33d0478

1 file changed

Lines changed: 29 additions & 6 deletions

File tree

scripts/export.py

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,18 @@
7474
_logger = logging.getLogger(__name__)
7575

7676

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+
7789
def _json_dump_safe(value) -> str:
7890
"""Best-effort JSON serialization for exclusion matching."""
7991
try:
@@ -165,6 +177,7 @@ def parse_args():
165177

166178

167179
def main():
180+
_configure_cli_logging()
168181
opts = parse_args()
169182
since = opts["since"]
170183
out_dir = os.path.abspath(opts["out_dir"])
@@ -215,10 +228,9 @@ def main():
215228

216229
with _open_global_db(workspace_path) as (global_db, global_db_path):
217230
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,
222234
)
223235
else:
224236
project_layouts_map = load_project_layouts_map(global_db)
@@ -347,7 +359,12 @@ def main():
347359
try:
348360
cli_projects = list_cli_projects(get_cli_chats_path())
349361
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+
)
351368
cli_projects = []
352369

353370
for cp in cli_projects:
@@ -378,7 +395,13 @@ def main():
378395
messages = traverse_blobs(session["db_path"])
379396
bubbles = messages_to_bubbles(messages, created_ms)
380397
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+
)
382405
continue
383406

384407
if not bubbles:

0 commit comments

Comments
 (0)