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