cleanup(contacts): Remove debug logging from last_seen feature

Feature is now working correctly:
- Parses 263 contacts (17 CLI + 226 REP + 20 ROOM)
- Displays accurate last_seen timestamps with activity indicators
- Shows relative time ("52 minutes ago", "1 year ago")
- Color-coded status: 🟢 active, 🟡 recent, 🔴 inactive

Removed excessive debug logging as it's no longer needed.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
MarekWo
2025-12-29 13:27:56 +01:00
parent 4c822e48e0
commit 4349171acf
2 changed files with 5 additions and 26 deletions
+5 -20
View File
@@ -561,19 +561,10 @@ def get_contacts_with_last_seen() -> Tuple[bool, Dict[str, Dict], str]:
logger.warning(f"apply_to {contact_type} contact_info failed: {stderr}")
continue # Skip this type, try next
logger.info(f"apply_to {contact_type} contact_info returned {len(stdout)} bytes")
# Parse NDJSON output (newline-delimited JSON)
# Output may be prettified JSON, not line-delimited
# Try to extract all JSON objects from the text
# Parse prettified JSON output
# Output contains multiple JSON objects separated by newlines
# Use brace-matching to extract each complete object
try:
# Log first 500 chars for debugging
logger.info(f"First 500 chars of {contact_type} output: {stdout[:500]}")
# Strategy: JSON objects might be prettified (multiline)
# We need to find all { ... } blocks
import re
# Find all complete JSON objects (balanced braces)
json_objects = []
depth = 0
@@ -594,21 +585,15 @@ def get_contacts_with_last_seen() -> Tuple[bool, Dict[str, Dict], str]:
if 'public_key' in contact:
json_objects.append(contact)
except json.JSONDecodeError:
logger.debug(f"Failed to parse JSON object at position {start_idx}")
# Skip malformed JSON
pass
start_idx = None
parsed_count = len(json_objects)
# Add to contacts dict
for contact in json_objects:
contacts_dict[contact['public_key']] = contact
# Log first contact for debugging
if len(contacts_dict) == 1:
logger.info(f"Sample contact: public_key={contact['public_key'][:12]}..., last_advert={contact.get('last_advert', 'MISSING')}")
logger.info(f"Parsed {parsed_count} contacts from {contact_type}")
logger.info(f"Parsed {len(json_objects)} contacts from {contact_type}")
except Exception as e:
logger.error(f"Error parsing {contact_type} output: {e}")
-6
View File
@@ -1245,11 +1245,8 @@ def get_contacts_detailed_api():
success_detailed, contacts_detailed, error_detailed = cli.get_contacts_with_last_seen()
if success_detailed:
logger.info(f"Got {len(contacts_detailed)} detailed contacts")
# Merge last_advert data with contacts
# Match by public_key_prefix (first 12 chars of full public_key)
matched_count = 0
for contact in contacts:
prefix = contact.get('public_key_prefix', '').lower()
@@ -1258,10 +1255,7 @@ def get_contacts_detailed_api():
if full_key.lower().startswith(prefix):
# Add last_seen timestamp
contact['last_seen'] = details.get('last_advert', None)
matched_count += 1
break
logger.info(f"Matched {matched_count} out of {len(contacts)} contacts with last_seen data")
else:
# If detailed fetch failed, log warning but still return contacts without last_seen
logger.warning(f"Failed to get last_seen data: {error_detailed}")