Compare commits

...

1 Commits

Author SHA1 Message Date
Eric Bailey 87d377a868 Make logs more clear 2025-09-05 10:14:07 -05:00
3 changed files with 33 additions and 17 deletions
+18 -2
View File
@@ -87,7 +87,21 @@ export function LogScreen({}: NativeStackScreenProps<
) : (
<CircleInfoIcon size="sm" />
)}
<Text style={[a.flex_1]}>{String(entry.message)}</Text>
<View
style={[
a.flex_1,
a.flex_row,
a.justify_start,
a.align_center,
a.gap_sm,
]}>
{entry.context && (
<Text style={[t.atoms.text_contrast_medium]}>
({String(entry.context)})
</Text>
)}
<Text>{String(entry.message)}</Text>
</View>
{entry.metadata &&
Object.keys(entry.metadata).length > 0 &&
(expanded.includes(entry.id) ? (
@@ -115,7 +129,9 @@ export function LogScreen({}: NativeStackScreenProps<
t.atoms.border_contrast_low,
]}>
<View style={[a.px_sm, a.py_xs]}>
<Text>{JSON.stringify(entry.metadata, null, 2)}</Text>
<Text style={[a.leading_snug, {fontFamily: 'monospace'}]}>
{JSON.stringify(entry.metadata, null, 2)}
</Text>
</View>
</View>
)}
+10 -12
View File
@@ -20,7 +20,7 @@ async function getGeolocationConfig(
})
if (!res.ok) {
throw new Error(`geolocation config: fetch failed ${res.status}`)
throw new Error(`config: fetch failed ${res.status}`)
}
const json = await res.json()
@@ -35,7 +35,7 @@ async function getGeolocationConfig(
ageRestrictedGeos: json.ageRestrictedGeos ?? [],
ageBlockedGeos: json.ageBlockedGeos ?? [],
}
logger.debug(`geolocation config: success`)
logger.debug(`config: success`)
return config
} else {
return undefined
@@ -85,7 +85,7 @@ export function beginResolveGeolocationConfig() {
} catch (e: any) {
success = false
logger.debug(`geolocation config: failed initial request`, {
logger.debug(`config: failed initial request`, {
safeMessage: e.message,
})
@@ -101,12 +101,12 @@ export function beginResolveGeolocationConfig() {
success = true
} else {
// endpoint should throw on all failures, this is insurance
throw new Error(`geolocation config: nothing returned from retries`)
throw new Error(`config: nothing returned from retries`)
}
})
.catch((e: any) => {
// complete fail closed
logger.debug(`geolocation config: failed retries`, {
logger.debug(`config: failed retries`, {
safeMessage: e.message,
})
})
@@ -123,21 +123,19 @@ export function beginResolveGeolocationConfig() {
*/
export async function ensureGeolocationConfigIsResolved() {
if (!geolocationConfigResolution) {
throw new Error(
`geolocation config: beginResolveGeolocationConfig not called yet`,
)
throw new Error(`config: beginResolveGeolocationConfig not called yet`)
}
const cached = device.get(['geolocation'])
if (cached) {
logger.debug(`geolocation config: using cache`)
logger.debug(`config: using cache`)
} else {
logger.debug(`geolocation config: no cache`)
logger.debug(`config: no cache`)
const {success} = await geolocationConfigResolution
if (success) {
logger.debug(`geolocation config: resolved`)
logger.debug(`config: resolved`)
} else {
logger.info(`geolocation config: failed to resolve`)
logger.info(`config: failed to resolve`)
}
}
}
+5 -3
View File
@@ -91,11 +91,13 @@ export function GeolocationStatusProvider({
const configContext = React.useMemo(() => ({config}), [config])
const statusContext = React.useMemo(() => {
if (deviceGeolocation) {
logger.debug('geolocation: has device geolocation available')
if (deviceGeolocation?.countryCode) {
logger.debug('has device geolocation available')
}
const geolocation = mergeGeolocation(deviceGeolocation, config)
const status = computeGeolocationStatus(geolocation, config)
// ensure this remains debug and never leaves device
logger.debug('result', {deviceGeolocation, geolocation, status, config})
return {location: geolocation, status}
}, [config, deviceGeolocation])
@@ -117,7 +119,7 @@ export function Provider({children}: {children: React.ReactNode}) {
const handleSetDeviceGeolocation = React.useCallback(
(location: DeviceLocation) => {
logger.debug('geolocation: setting device geolocation')
logger.debug('setting device geolocation')
setDeviceGeolocation({
countryCode: location.countryCode ?? undefined,
regionCode: location.regionCode ?? undefined,