Merge pull request #1813 from bluesky-social/eric/app-903-extract-logger-into-singleton
Add new logger
This commit is contained in:
commit
e49a3d8a56
70 changed files with 1109 additions and 176 deletions
|
@ -10,6 +10,7 @@ import {s} from 'lib/styles'
|
|||
import {ViewHeader} from '../com/util/ViewHeader'
|
||||
import {Text} from '../com/util/text/Text'
|
||||
import {usePalette} from 'lib/hooks/usePalette'
|
||||
import {getEntries} from '#/logger/logDump'
|
||||
import {ago} from 'lib/strings/time'
|
||||
|
||||
export const LogScreen = observer(function Log({}: NativeStackScreenProps<
|
||||
|
@ -38,9 +39,8 @@ export const LogScreen = observer(function Log({}: NativeStackScreenProps<
|
|||
<View style={[s.flex1]}>
|
||||
<ViewHeader title="Log" />
|
||||
<ScrollView style={s.flex1}>
|
||||
{store.log.entries
|
||||
{getEntries()
|
||||
.slice(0)
|
||||
.reverse()
|
||||
.map(entry => {
|
||||
return (
|
||||
<View key={`entry-${entry.id}`}>
|
||||
|
@ -49,15 +49,15 @@ export const LogScreen = observer(function Log({}: NativeStackScreenProps<
|
|||
onPress={toggler(entry.id)}
|
||||
accessibilityLabel="View debug entry"
|
||||
accessibilityHint="Opens additional details for a debug entry">
|
||||
{entry.type === 'debug' ? (
|
||||
{entry.level === 'debug' ? (
|
||||
<FontAwesomeIcon icon="info" />
|
||||
) : (
|
||||
<FontAwesomeIcon icon="exclamation" style={s.red3} />
|
||||
)}
|
||||
<Text type="sm" style={[styles.summary, pal.text]}>
|
||||
{entry.summary}
|
||||
{String(entry.message)}
|
||||
</Text>
|
||||
{entry.details ? (
|
||||
{entry.metadata && Object.keys(entry.metadata).length ? (
|
||||
<FontAwesomeIcon
|
||||
icon={
|
||||
expanded.includes(entry.id) ? 'angle-up' : 'angle-down'
|
||||
|
@ -66,14 +66,14 @@ export const LogScreen = observer(function Log({}: NativeStackScreenProps<
|
|||
/>
|
||||
) : undefined}
|
||||
<Text type="sm" style={[styles.ts, pal.textLight]}>
|
||||
{entry.ts ? ago(entry.ts) : ''}
|
||||
{ago(entry.timestamp)}
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
{expanded.includes(entry.id) ? (
|
||||
<View style={[pal.view, s.pl10, s.pr10, s.pb10]}>
|
||||
<View style={[pal.btn, styles.details]}>
|
||||
<Text type="mono" style={pal.text}>
|
||||
{entry.details}
|
||||
{JSON.stringify(entry.metadata, null, 2)}
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
|
|
|
@ -52,7 +52,7 @@ export const ModerationBlockedAccounts = withAuthRequired(
|
|||
blockedAccounts
|
||||
.loadMore()
|
||||
.catch(err =>
|
||||
store.log.error('Failed to load more blocked accounts', err),
|
||||
store.log.error('Failed to load more blocked accounts', {error: err}),
|
||||
)
|
||||
}, [blockedAccounts, store])
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ export const ModerationMutedAccounts = withAuthRequired(
|
|||
mutedAccounts
|
||||
.loadMore()
|
||||
.catch(err =>
|
||||
store.log.error('Failed to load more muted accounts', err),
|
||||
store.log.error('Failed to load more muted accounts', {error: err}),
|
||||
)
|
||||
}, [mutedAccounts, store])
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ export const PostThreadScreen = withAuthRequired(
|
|||
InteractionManager.runAfterInteractions(() => {
|
||||
if (!view.hasLoaded && !view.isLoading) {
|
||||
view.setup().catch(err => {
|
||||
store.log.error('Failed to fetch thread', err)
|
||||
store.log.error('Failed to fetch thread', {error: err})
|
||||
})
|
||||
}
|
||||
})
|
||||
|
|
|
@ -108,15 +108,15 @@ export const ProfileScreen = withAuthRequired(
|
|||
uiState
|
||||
.refresh()
|
||||
.catch((err: any) =>
|
||||
store.log.error('Failed to refresh user profile', err),
|
||||
store.log.error('Failed to refresh user profile', {error: err}),
|
||||
)
|
||||
}, [uiState, store])
|
||||
const onEndReached = React.useCallback(() => {
|
||||
uiState
|
||||
.loadMore()
|
||||
.catch((err: any) =>
|
||||
store.log.error('Failed to load more entries in user profile', err),
|
||||
)
|
||||
uiState.loadMore().catch((err: any) =>
|
||||
store.log.error('Failed to load more entries in user profile', {
|
||||
error: err,
|
||||
}),
|
||||
)
|
||||
}, [uiState, store])
|
||||
const onPressTryAgain = React.useCallback(() => {
|
||||
uiState.setup()
|
||||
|
|
|
@ -165,7 +165,7 @@ export const ProfileFeedScreenInner = observer(
|
|||
Toast.show(
|
||||
'There was an an issue updating your feeds, please check your internet connection and try again.',
|
||||
)
|
||||
store.log.error('Failed up update feeds', {err})
|
||||
store.log.error('Failed up update feeds', {error: err})
|
||||
}
|
||||
}, [store, feedInfo])
|
||||
|
||||
|
@ -181,7 +181,7 @@ export const ProfileFeedScreenInner = observer(
|
|||
Toast.show(
|
||||
'There was an an issue contacting the server, please check your internet connection and try again.',
|
||||
)
|
||||
store.log.error('Failed up toggle like', {err})
|
||||
store.log.error('Failed up toggle like', {error: err})
|
||||
}
|
||||
}, [store, feedInfo])
|
||||
|
||||
|
@ -190,7 +190,7 @@ export const ProfileFeedScreenInner = observer(
|
|||
if (feedInfo) {
|
||||
feedInfo.togglePin().catch(e => {
|
||||
Toast.show('There was an issue contacting the server')
|
||||
store.log.error('Failed to toggle pinned feed', {e})
|
||||
store.log.error('Failed to toggle pinned feed', {error: e})
|
||||
})
|
||||
}
|
||||
}, [store, feedInfo])
|
||||
|
|
|
@ -272,7 +272,7 @@ const Header = observer(function HeaderImpl({
|
|||
Haptics.default()
|
||||
list.togglePin().catch(e => {
|
||||
Toast.show('There was an issue contacting the server')
|
||||
store.log.error('Failed to toggle pinned list', {e})
|
||||
store.log.error('Failed to toggle pinned list', {error: e})
|
||||
})
|
||||
}, [store, list])
|
||||
|
||||
|
|
|
@ -166,14 +166,14 @@ const ListItem = observer(function ListItemImpl({
|
|||
Haptics.default()
|
||||
item.togglePin().catch(e => {
|
||||
Toast.show('There was an issue contacting the server')
|
||||
store.log.error('Failed to toggle pinned feed', {e})
|
||||
store.log.error('Failed to toggle pinned feed', {error: e})
|
||||
})
|
||||
}, [item, store])
|
||||
const onPressUp = useCallback(
|
||||
() =>
|
||||
savedFeeds.movePinnedFeed(item, 'up').catch(e => {
|
||||
Toast.show('There was an issue contacting the server')
|
||||
store.log.error('Failed to set pinned feed order', {e})
|
||||
store.log.error('Failed to set pinned feed order', {error: e})
|
||||
}),
|
||||
[store, savedFeeds, item],
|
||||
)
|
||||
|
@ -181,7 +181,7 @@ const ListItem = observer(function ListItemImpl({
|
|||
() =>
|
||||
savedFeeds.movePinnedFeed(item, 'down').catch(e => {
|
||||
Toast.show('There was an issue contacting the server')
|
||||
store.log.error('Failed to set pinned feed order', {e})
|
||||
store.log.error('Failed to set pinned feed order', {error: e})
|
||||
}),
|
||||
[store, savedFeeds, item],
|
||||
)
|
||||
|
|
|
@ -112,7 +112,7 @@ export const SettingsScreen = withAuthRequired(
|
|||
err => {
|
||||
store.log.error(
|
||||
'Failed to reload from server after handle update',
|
||||
{err},
|
||||
{error: err},
|
||||
)
|
||||
setIsSwitching(false)
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue