import React from 'react'; import { View, Text, StyleSheet, ScrollView } from 'react-native'; import { Colors } from '../../ui/theme/colors'; import { FontSize, FontWeight, Radius, Spacing } from '../../ui/theme/layout'; import { safeStringify } from '../../utils/safeStringify'; import { CollapsibleSection } from '../../ui/shared/CollapsibleSection'; import { JsonView } from '../../ui/shared/JsonView'; import { CopyButton } from '../../ui/shared/CopyButton'; import { LogListScreen } from '../../ui/shared/LogListScreen'; import { LogRow } from '../../ui/shared/LogRow'; import { fmt } from '../../utils/copyToComputer'; import { LEVEL_COLORS, LEVEL_ICONS } from '../../constants/logLevels'; import type { ConsoleLogEntry, DebugFeatureRenderProps } from '../../types'; import { t } from '../../i18n'; export function renderConsoleLogRow(item: ConsoleLogEntry) { return ( ( typeof d === 'string' ? d : safeStringify(d) )).join(' ')} contentStyle={s.logMessage} metadata={( {LEVEL_ICONS[item.level] ?? '●'} )} trailingMetadata={( {new Date(item.timestamp).toLocaleTimeString()} )} /> ); } export const ConsoleLogTab: React.FC> = React.memo(({ snapshot }) => ( ( <> {item.level.toUpperCase()} {new Date(item.timestamp).toLocaleString()} )} renderDetailBody={(item) => ( {item.data.map((d, index) => { const formatted = typeof d === 'object' && d !== null ? fmt(d) : String(d); return ( {typeof d === 'object' && d !== null ? ( ) : ( {String(d)} )} ); })} )} /> )); const s = StyleSheet.create({ levelDot: { width: 20, height: 20, borderRadius: 10, alignItems: 'center', justifyContent: 'center', }, levelIcon: { color: Colors.textInverse, fontSize: FontSize.XXS, fontWeight: FontWeight.bold }, logMessage: { fontSize: FontSize.MD, color: Colors.text, lineHeight: 18 }, time: { fontSize: FontSize.XS, color: Colors.textSecondary }, levelBadge: { paddingHorizontal: Spacing.MD, paddingVertical: Spacing.XXS, borderRadius: Radius.SM }, levelBadgeText: { color: Colors.textInverse, fontSize: FontSize.XS, fontWeight: FontWeight.bold }, detailTime: { flex: 1, fontSize: FontSize.SM, color: Colors.textSecondary, textAlign: 'right' }, detailBody: { flex: 1 }, detailBodyContent: { padding: Spacing.MD }, sectionWithCopy: { gap: Spacing.SM }, plainText: { fontFamily: 'Courier', fontSize: FontSize.SM, color: Colors.text, lineHeight: 18 }, });