Replace all logs with new logger
This commit is contained in:
parent
e49a3d8a56
commit
f51351e80d
66 changed files with 301 additions and 230 deletions
|
|
@ -17,6 +17,7 @@ import {bundleAsync} from 'lib/async/bundle'
|
|||
import {RootStoreModel} from '../root-store'
|
||||
import {PostThreadModel} from '../content/post-thread'
|
||||
import {cleanError} from 'lib/strings/errors'
|
||||
import {logger} from '#/logger'
|
||||
|
||||
const GROUPABLE_REASONS = ['like', 'repost', 'follow']
|
||||
const PAGE_SIZE = 30
|
||||
|
|
@ -210,7 +211,7 @@ export class NotificationsFeedItemModel {
|
|||
if (valid.success) {
|
||||
return v
|
||||
} else {
|
||||
this.rootStore.log.warn('Received an invalid record', {
|
||||
logger.warn('Received an invalid record', {
|
||||
record: v,
|
||||
error: valid.error,
|
||||
})
|
||||
|
|
@ -218,7 +219,7 @@ export class NotificationsFeedItemModel {
|
|||
}
|
||||
}
|
||||
}
|
||||
this.rootStore.log.warn(
|
||||
logger.warn(
|
||||
'app.bsky.notifications.list served an unsupported record type',
|
||||
{record: v},
|
||||
)
|
||||
|
|
@ -319,7 +320,7 @@ export class NotificationsFeedModel {
|
|||
* Nuke all data
|
||||
*/
|
||||
clear() {
|
||||
this.rootStore.log.debug('NotificationsModel:clear')
|
||||
logger.debug('NotificationsModel:clear')
|
||||
this.isLoading = false
|
||||
this.isRefreshing = false
|
||||
this.hasLoaded = false
|
||||
|
|
@ -336,7 +337,7 @@ export class NotificationsFeedModel {
|
|||
* Load for first render
|
||||
*/
|
||||
setup = bundleAsync(async (isRefreshing: boolean = false) => {
|
||||
this.rootStore.log.debug('NotificationsModel:refresh', {isRefreshing})
|
||||
logger.debug('NotificationsModel:refresh', {isRefreshing})
|
||||
await this.lock.acquireAsync()
|
||||
try {
|
||||
this._xLoading(isRefreshing)
|
||||
|
|
@ -368,7 +369,7 @@ export class NotificationsFeedModel {
|
|||
* Sync the next set of notifications to show
|
||||
*/
|
||||
syncQueue = bundleAsync(async () => {
|
||||
this.rootStore.log.debug('NotificationsModel:syncQueue')
|
||||
logger.debug('NotificationsModel:syncQueue')
|
||||
if (this.unreadCount >= MAX_VISIBLE_NOTIFS) {
|
||||
return // no need to check
|
||||
}
|
||||
|
|
@ -401,7 +402,7 @@ export class NotificationsFeedModel {
|
|||
this._setQueued(this._filterNotifications(queueModels))
|
||||
this._countUnread()
|
||||
} catch (e) {
|
||||
this.rootStore.log.error('NotificationsModel:syncQueue failed', {
|
||||
logger.error('NotificationsModel:syncQueue failed', {
|
||||
error: e,
|
||||
})
|
||||
} finally {
|
||||
|
|
@ -463,10 +464,7 @@ export class NotificationsFeedModel {
|
|||
}
|
||||
}
|
||||
await Promise.all(promises).catch(e => {
|
||||
this.rootStore.log.error(
|
||||
'Uncaught failure during notifications update()',
|
||||
e,
|
||||
)
|
||||
logger.error('Uncaught failure during notifications update()', e)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -483,7 +481,7 @@ export class NotificationsFeedModel {
|
|||
this.lastSync ? this.lastSync.toISOString() : undefined,
|
||||
)
|
||||
} catch (e: any) {
|
||||
this.rootStore.log.warn('Failed to update notifications read state', {
|
||||
logger.warn('Failed to update notifications read state', {
|
||||
error: e,
|
||||
})
|
||||
}
|
||||
|
|
@ -505,10 +503,10 @@ export class NotificationsFeedModel {
|
|||
this.error = cleanError(error)
|
||||
this.loadMoreError = cleanError(loadMoreError)
|
||||
if (error) {
|
||||
this.rootStore.log.error('Failed to fetch notifications', {error})
|
||||
logger.error('Failed to fetch notifications', {error})
|
||||
}
|
||||
if (loadMoreError) {
|
||||
this.rootStore.log.error('Failed to load more notifications', {
|
||||
logger.error('Failed to load more notifications', {
|
||||
error: loadMoreError,
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import {RootStoreModel} from '../root-store'
|
|||
import {updateDataOptimistically} from 'lib/async/revertible'
|
||||
import {track} from 'lib/analytics/analytics'
|
||||
import {hackAddDeletedEmbed} from 'lib/api/hack-add-deleted-embed'
|
||||
import {logger} from '#/logger'
|
||||
|
||||
type FeedViewPost = AppBskyFeedDefs.FeedViewPost
|
||||
type ReasonRepost = AppBskyFeedDefs.ReasonRepost
|
||||
|
|
@ -42,14 +43,14 @@ export class PostsFeedItemModel {
|
|||
} else {
|
||||
this.postRecord = undefined
|
||||
this.richText = undefined
|
||||
rootStore.log.warn('Received an invalid app.bsky.feed.post record', {
|
||||
logger.warn('Received an invalid app.bsky.feed.post record', {
|
||||
error: valid.error,
|
||||
})
|
||||
}
|
||||
} else {
|
||||
this.postRecord = undefined
|
||||
this.richText = undefined
|
||||
rootStore.log.warn(
|
||||
logger.warn(
|
||||
'app.bsky.feed.getTimeline or app.bsky.feed.getAuthorFeed served an unexpected record type',
|
||||
{record: this.post.record},
|
||||
)
|
||||
|
|
@ -132,7 +133,7 @@ export class PostsFeedItemModel {
|
|||
track('Post:Like')
|
||||
}
|
||||
} catch (error) {
|
||||
this.rootStore.log.error('Failed to toggle like', {error})
|
||||
logger.error('Failed to toggle like', {error})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -167,7 +168,7 @@ export class PostsFeedItemModel {
|
|||
track('Post:Repost')
|
||||
}
|
||||
} catch (error) {
|
||||
this.rootStore.log.error('Failed to toggle repost', {error})
|
||||
logger.error('Failed to toggle repost', {error})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -181,7 +182,7 @@ export class PostsFeedItemModel {
|
|||
track('Post:ThreadMute')
|
||||
}
|
||||
} catch (error) {
|
||||
this.rootStore.log.error('Failed to toggle thread mute', {error})
|
||||
logger.error('Failed to toggle thread mute', {error})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -190,7 +191,7 @@ export class PostsFeedItemModel {
|
|||
await this.rootStore.agent.deletePost(this.post.uri)
|
||||
this.rootStore.emitPostDeleted(this.post.uri)
|
||||
} catch (error) {
|
||||
this.rootStore.log.error('Failed to delete post', {error})
|
||||
logger.error('Failed to delete post', {error})
|
||||
} finally {
|
||||
track('Post:Delete')
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import {LikesFeedAPI} from 'lib/api/feed/likes'
|
|||
import {CustomFeedAPI} from 'lib/api/feed/custom'
|
||||
import {ListFeedAPI} from 'lib/api/feed/list'
|
||||
import {MergeFeedAPI} from 'lib/api/feed/merge'
|
||||
import {logger} from '#/logger'
|
||||
|
||||
const PAGE_SIZE = 30
|
||||
|
||||
|
|
@ -161,7 +162,7 @@ export class PostsFeedModel {
|
|||
* Nuke all data
|
||||
*/
|
||||
clear() {
|
||||
this.rootStore.log.debug('FeedModel:clear')
|
||||
logger.debug('FeedModel:clear')
|
||||
this.isLoading = false
|
||||
this.isRefreshing = false
|
||||
this.hasNewLatest = false
|
||||
|
|
@ -177,7 +178,7 @@ export class PostsFeedModel {
|
|||
* Load for first render
|
||||
*/
|
||||
setup = bundleAsync(async (isRefreshing: boolean = false) => {
|
||||
this.rootStore.log.debug('FeedModel:setup', {isRefreshing})
|
||||
logger.debug('FeedModel:setup', {isRefreshing})
|
||||
if (isRefreshing) {
|
||||
this.isRefreshing = true // set optimistically for UI
|
||||
}
|
||||
|
|
@ -324,10 +325,10 @@ export class PostsFeedModel {
|
|||
this.knownError = detectKnownError(this.feedType, error)
|
||||
this.loadMoreError = cleanError(loadMoreError)
|
||||
if (error) {
|
||||
this.rootStore.log.error('Posts feed request failed', {error})
|
||||
logger.error('Posts feed request failed', {error})
|
||||
}
|
||||
if (loadMoreError) {
|
||||
this.rootStore.log.error('Posts feed load-more request failed', {
|
||||
logger.error('Posts feed load-more request failed', {
|
||||
error: loadMoreError,
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue