Bluesky app fork with some witchin' additions 💫

Make logs more clear (#8991)

authored by

Eric Bailey and committed by
GitHub
0f089060 01ba0d0e

+33 -17
+18 -2
src/screens/Log.tsx
··· 87 87 ) : ( 88 88 <CircleInfoIcon size="sm" /> 89 89 )} 90 - <Text style={[a.flex_1]}>{String(entry.message)}</Text> 90 + <View 91 + style={[ 92 + a.flex_1, 93 + a.flex_row, 94 + a.justify_start, 95 + a.align_center, 96 + a.gap_sm, 97 + ]}> 98 + {entry.context && ( 99 + <Text style={[t.atoms.text_contrast_medium]}> 100 + ({String(entry.context)}) 101 + </Text> 102 + )} 103 + <Text>{String(entry.message)}</Text> 104 + </View> 91 105 {entry.metadata && 92 106 Object.keys(entry.metadata).length > 0 && 93 107 (expanded.includes(entry.id) ? ( ··· 115 129 t.atoms.border_contrast_low, 116 130 ]}> 117 131 <View style={[a.px_sm, a.py_xs]}> 118 - <Text>{JSON.stringify(entry.metadata, null, 2)}</Text> 132 + <Text style={[a.leading_snug, {fontFamily: 'monospace'}]}> 133 + {JSON.stringify(entry.metadata, null, 2)} 134 + </Text> 119 135 </View> 120 136 </View> 121 137 )}
+10 -12
src/state/geolocation/config.ts
··· 20 20 }) 21 21 22 22 if (!res.ok) { 23 - throw new Error(`geolocation config: fetch failed ${res.status}`) 23 + throw new Error(`config: fetch failed ${res.status}`) 24 24 } 25 25 26 26 const json = await res.json() ··· 35 35 ageRestrictedGeos: json.ageRestrictedGeos ?? [], 36 36 ageBlockedGeos: json.ageBlockedGeos ?? [], 37 37 } 38 - logger.debug(`geolocation config: success`) 38 + logger.debug(`config: success`) 39 39 return config 40 40 } else { 41 41 return undefined ··· 85 85 } catch (e: any) { 86 86 success = false 87 87 88 - logger.debug(`geolocation config: failed initial request`, { 88 + logger.debug(`config: failed initial request`, { 89 89 safeMessage: e.message, 90 90 }) 91 91 ··· 101 101 success = true 102 102 } else { 103 103 // endpoint should throw on all failures, this is insurance 104 - throw new Error(`geolocation config: nothing returned from retries`) 104 + throw new Error(`config: nothing returned from retries`) 105 105 } 106 106 }) 107 107 .catch((e: any) => { 108 108 // complete fail closed 109 - logger.debug(`geolocation config: failed retries`, { 109 + logger.debug(`config: failed retries`, { 110 110 safeMessage: e.message, 111 111 }) 112 112 }) ··· 123 123 */ 124 124 export async function ensureGeolocationConfigIsResolved() { 125 125 if (!geolocationConfigResolution) { 126 - throw new Error( 127 - `geolocation config: beginResolveGeolocationConfig not called yet`, 128 - ) 126 + throw new Error(`config: beginResolveGeolocationConfig not called yet`) 129 127 } 130 128 131 129 const cached = device.get(['geolocation']) 132 130 if (cached) { 133 - logger.debug(`geolocation config: using cache`) 131 + logger.debug(`config: using cache`) 134 132 } else { 135 - logger.debug(`geolocation config: no cache`) 133 + logger.debug(`config: no cache`) 136 134 const {success} = await geolocationConfigResolution 137 135 if (success) { 138 - logger.debug(`geolocation config: resolved`) 136 + logger.debug(`config: resolved`) 139 137 } else { 140 - logger.info(`geolocation config: failed to resolve`) 138 + logger.info(`config: failed to resolve`) 141 139 } 142 140 } 143 141 }
+5 -3
src/state/geolocation/index.tsx
··· 91 91 92 92 const configContext = React.useMemo(() => ({config}), [config]) 93 93 const statusContext = React.useMemo(() => { 94 - if (deviceGeolocation) { 95 - logger.debug('geolocation: has device geolocation available') 94 + if (deviceGeolocation?.countryCode) { 95 + logger.debug('has device geolocation available') 96 96 } 97 97 const geolocation = mergeGeolocation(deviceGeolocation, config) 98 98 const status = computeGeolocationStatus(geolocation, config) 99 + // ensure this remains debug and never leaves device 100 + logger.debug('result', {deviceGeolocation, geolocation, status, config}) 99 101 return {location: geolocation, status} 100 102 }, [config, deviceGeolocation]) 101 103 ··· 117 119 118 120 const handleSetDeviceGeolocation = React.useCallback( 119 121 (location: DeviceLocation) => { 120 - logger.debug('geolocation: setting device geolocation') 122 + logger.debug('setting device geolocation') 121 123 setDeviceGeolocation({ 122 124 countryCode: location.countryCode ?? undefined, 123 125 regionCode: location.regionCode ?? undefined,