Make logs more clear (#8991)
This commit is contained in:
+18
-2
@@ -87,7 +87,21 @@ export function LogScreen({}: NativeStackScreenProps<
|
|||||||
) : (
|
) : (
|
||||||
<CircleInfoIcon size="sm" />
|
<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 &&
|
{entry.metadata &&
|
||||||
Object.keys(entry.metadata).length > 0 &&
|
Object.keys(entry.metadata).length > 0 &&
|
||||||
(expanded.includes(entry.id) ? (
|
(expanded.includes(entry.id) ? (
|
||||||
@@ -115,7 +129,9 @@ export function LogScreen({}: NativeStackScreenProps<
|
|||||||
t.atoms.border_contrast_low,
|
t.atoms.border_contrast_low,
|
||||||
]}>
|
]}>
|
||||||
<View style={[a.px_sm, a.py_xs]}>
|
<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>
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ async function getGeolocationConfig(
|
|||||||
})
|
})
|
||||||
|
|
||||||
if (!res.ok) {
|
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()
|
const json = await res.json()
|
||||||
@@ -35,7 +35,7 @@ async function getGeolocationConfig(
|
|||||||
ageRestrictedGeos: json.ageRestrictedGeos ?? [],
|
ageRestrictedGeos: json.ageRestrictedGeos ?? [],
|
||||||
ageBlockedGeos: json.ageBlockedGeos ?? [],
|
ageBlockedGeos: json.ageBlockedGeos ?? [],
|
||||||
}
|
}
|
||||||
logger.debug(`geolocation config: success`)
|
logger.debug(`config: success`)
|
||||||
return config
|
return config
|
||||||
} else {
|
} else {
|
||||||
return undefined
|
return undefined
|
||||||
@@ -85,7 +85,7 @@ export function beginResolveGeolocationConfig() {
|
|||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
success = false
|
success = false
|
||||||
|
|
||||||
logger.debug(`geolocation config: failed initial request`, {
|
logger.debug(`config: failed initial request`, {
|
||||||
safeMessage: e.message,
|
safeMessage: e.message,
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -101,12 +101,12 @@ export function beginResolveGeolocationConfig() {
|
|||||||
success = true
|
success = true
|
||||||
} else {
|
} else {
|
||||||
// endpoint should throw on all failures, this is insurance
|
// 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) => {
|
.catch((e: any) => {
|
||||||
// complete fail closed
|
// complete fail closed
|
||||||
logger.debug(`geolocation config: failed retries`, {
|
logger.debug(`config: failed retries`, {
|
||||||
safeMessage: e.message,
|
safeMessage: e.message,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -123,21 +123,19 @@ export function beginResolveGeolocationConfig() {
|
|||||||
*/
|
*/
|
||||||
export async function ensureGeolocationConfigIsResolved() {
|
export async function ensureGeolocationConfigIsResolved() {
|
||||||
if (!geolocationConfigResolution) {
|
if (!geolocationConfigResolution) {
|
||||||
throw new Error(
|
throw new Error(`config: beginResolveGeolocationConfig not called yet`)
|
||||||
`geolocation config: beginResolveGeolocationConfig not called yet`,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const cached = device.get(['geolocation'])
|
const cached = device.get(['geolocation'])
|
||||||
if (cached) {
|
if (cached) {
|
||||||
logger.debug(`geolocation config: using cache`)
|
logger.debug(`config: using cache`)
|
||||||
} else {
|
} else {
|
||||||
logger.debug(`geolocation config: no cache`)
|
logger.debug(`config: no cache`)
|
||||||
const {success} = await geolocationConfigResolution
|
const {success} = await geolocationConfigResolution
|
||||||
if (success) {
|
if (success) {
|
||||||
logger.debug(`geolocation config: resolved`)
|
logger.debug(`config: resolved`)
|
||||||
} else {
|
} else {
|
||||||
logger.info(`geolocation config: failed to resolve`)
|
logger.info(`config: failed to resolve`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,11 +91,13 @@ export function GeolocationStatusProvider({
|
|||||||
|
|
||||||
const configContext = React.useMemo(() => ({config}), [config])
|
const configContext = React.useMemo(() => ({config}), [config])
|
||||||
const statusContext = React.useMemo(() => {
|
const statusContext = React.useMemo(() => {
|
||||||
if (deviceGeolocation) {
|
if (deviceGeolocation?.countryCode) {
|
||||||
logger.debug('geolocation: has device geolocation available')
|
logger.debug('has device geolocation available')
|
||||||
}
|
}
|
||||||
const geolocation = mergeGeolocation(deviceGeolocation, config)
|
const geolocation = mergeGeolocation(deviceGeolocation, config)
|
||||||
const status = computeGeolocationStatus(geolocation, 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}
|
return {location: geolocation, status}
|
||||||
}, [config, deviceGeolocation])
|
}, [config, deviceGeolocation])
|
||||||
|
|
||||||
@@ -117,7 +119,7 @@ export function Provider({children}: {children: React.ReactNode}) {
|
|||||||
|
|
||||||
const handleSetDeviceGeolocation = React.useCallback(
|
const handleSetDeviceGeolocation = React.useCallback(
|
||||||
(location: DeviceLocation) => {
|
(location: DeviceLocation) => {
|
||||||
logger.debug('geolocation: setting device geolocation')
|
logger.debug('setting device geolocation')
|
||||||
setDeviceGeolocation({
|
setDeviceGeolocation({
|
||||||
countryCode: location.countryCode ?? undefined,
|
countryCode: location.countryCode ?? undefined,
|
||||||
regionCode: location.regionCode ?? undefined,
|
regionCode: location.regionCode ?? undefined,
|
||||||
|
|||||||
Reference in New Issue
Block a user