Merge pull request #1813 from bluesky-social/eric/app-903-extract-logger-into-singleton

Add new logger
This commit is contained in:
Eric Bailey 2023-11-04 13:12:46 -05:00 committed by GitHub
commit e49a3d8a56
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
70 changed files with 1109 additions and 176 deletions

View file

@ -178,10 +178,9 @@ export async function post(store: RootStoreModel, opts: PostOpts) {
) {
encoding = 'image/jpeg'
} else {
store.log.warn(
'Unexpected image format for thumbnail, skipping',
opts.extLink.localThumb.path,
)
store.log.warn('Unexpected image format for thumbnail, skipping', {
thumbnail: opts.extLink.localThumb.path,
})
}
if (encoding) {
const thumbUploadRes = await uploadBlob(

View file

@ -22,7 +22,7 @@ export function useFollowProfile(profile: AppBskyActorDefs.ProfileViewBasic) {
following: false,
}
} catch (e: any) {
store.log.error('Failed to delete follow', e)
store.log.error('Failed to delete follow', {error: e})
throw e
}
} else if (state === FollowState.NotFollowing) {
@ -40,7 +40,7 @@ export function useFollowProfile(profile: AppBskyActorDefs.ProfileViewBasic) {
following: true,
}
} catch (e: any) {
store.log.error('Failed to create follow', e)
store.log.error('Failed to create follow', {error: e})
throw e
}
}

View file

@ -34,18 +34,18 @@ export function useOTAUpdate() {
// show a popup modal
showUpdatePopup()
} catch (e) {
console.error('useOTAUpdate: Error while checking for update', e)
store.log.error('useOTAUpdate: Error while checking for update', e)
store.log.error('useOTAUpdate: Error while checking for update', {
error: e,
})
}
}, [showUpdatePopup, store.log])
const updateEventListener = useCallback(
(event: Updates.UpdateEvent) => {
store.log.debug('useOTAUpdate: Listening for update...')
if (event.type === Updates.UpdateEventType.ERROR) {
store.log.error(
'useOTAUpdate: Error while listening for update',
event.message,
)
store.log.error('useOTAUpdate: Error while listening for update', {
message: event.message,
})
} else if (event.type === Updates.UpdateEventType.NO_UPDATE_AVAILABLE) {
// Handle no update available
// do nothing

View file

@ -30,18 +30,18 @@ export function init(store: RootStoreModel) {
appId: 'xyz.blueskyweb.app',
})
store.log.debug('Notifications: Sent push token (init)', {
type: token.type,
tokenType: token.type,
token: token.data,
})
} catch (error) {
store.log.error('Notifications: Failed to set push token', error)
store.log.error('Notifications: Failed to set push token', {error})
}
}
// listens for new changes to the push token
// In rare situations, a push token may be changed by the push notification service while the app is running. When a token is rolled, the old one becomes invalid and sending notifications to it will fail. A push token listener will let you handle this situation gracefully by registering the new token with your backend right away.
Notifications.addPushTokenListener(async ({data: t, type}) => {
store.log.debug('Notifications: Push token changed', {t, type})
store.log.debug('Notifications: Push token changed', {t, tokenType: type})
if (t) {
try {
await store.agent.api.app.bsky.notification.registerPush({
@ -51,11 +51,11 @@ export function init(store: RootStoreModel) {
appId: 'xyz.blueskyweb.app',
})
store.log.debug('Notifications: Sent push token (event)', {
type,
tokenType: type,
token: t,
})
} catch (error) {
store.log.error('Notifications: Failed to set push token', error)
store.log.error('Notifications: Failed to set push token', {error})
}
}
})
@ -63,7 +63,7 @@ export function init(store: RootStoreModel) {
// handle notifications that are received, both in the foreground or background
Notifications.addNotificationReceivedListener(event => {
store.log.debug('Notifications: received', event)
store.log.debug('Notifications: received', {event})
if (event.request.trigger.type === 'push') {
// refresh notifications in the background
store.me.notifications.syncQueue()
@ -84,10 +84,9 @@ export function init(store: RootStoreModel) {
// handle notifications that are tapped on
const sub = Notifications.addNotificationResponseReceivedListener(
response => {
store.log.debug(
'Notifications: response received',
response.actionIdentifier,
)
store.log.debug('Notifications: response received', {
actionIdentifier: response.actionIdentifier,
})
if (
response.actionIdentifier === Notifications.DEFAULT_ACTION_IDENTIFIER
) {