forked from shadowfacts/Tusker
Better TimelineLikeController logging
This commit is contained in:
parent
db7c183d06
commit
d003098146
|
@ -116,7 +116,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
|||
let objClazz = clazz as AnyObject as? NSObjectProtocol,
|
||||
objClazz.responds(to: Selector(("id"))),
|
||||
let id = objClazz.perform(Selector(("id"))).takeUnretainedValue() as? String {
|
||||
logger.info("Initialized Sentry with installation/user ID: \(id)")
|
||||
logger.info("Initialized Sentry with installation/user ID: \(id, privacy: .public)")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ class NotificationsCollectionViewController: UIViewController, TimelineLikeColle
|
|||
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
|
||||
self.controller = TimelineLikeController(delegate: self)
|
||||
self.controller = TimelineLikeController(delegate: self, ownerType: String(describing: self))
|
||||
|
||||
addKeyCommand(MenuController.refreshCommand(discoverabilityTitle: "Refresh Notifications"))
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ class ProfileStatusesViewController: UIViewController, TimelineLikeCollectionVie
|
|||
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
|
||||
self.controller = TimelineLikeController(delegate: self)
|
||||
self.controller = TimelineLikeController(delegate: self, ownerType: String(describing: self))
|
||||
|
||||
addKeyCommand(MenuController.refreshCommand(discoverabilityTitle: "Refresh Profile"))
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
|
|||
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
|
||||
self.controller = TimelineLikeController(delegate: self)
|
||||
self.controller = TimelineLikeController(delegate: self, ownerType: String(describing: self))
|
||||
|
||||
self.navigationItem.title = timeline.title
|
||||
addKeyCommand(MenuController.refreshCommand(discoverabilityTitle: "Refresh Timeline"))
|
||||
|
|
|
@ -40,19 +40,21 @@ private let logger = Logger(subsystem: Bundle.main.bundleIdentifier!, category:
|
|||
class TimelineLikeController<Item: Sendable> {
|
||||
|
||||
private unowned var delegate: any TimelineLikeControllerDelegate<Item>
|
||||
private let ownerType: String
|
||||
|
||||
private(set) var state = State.notLoadedInitial {
|
||||
willSet {
|
||||
guard state.canTransition(to: newValue) else {
|
||||
logger.error("State \(self.state.debugDescription, privacy: .public) cannot transition to \(newValue.debugDescription, privacy: .public)")
|
||||
logger.error("\(self.ownerType, privacy: .public) State \(self.state.debugDescription, privacy: .public) cannot transition to \(newValue.debugDescription, privacy: .public)")
|
||||
fatalError("State \(state) cannot transition to \(newValue)")
|
||||
}
|
||||
logger.debug("State: \(self.state.debugDescription, privacy: .public) -> \(newValue.debugDescription, privacy: .public)")
|
||||
logger.debug("\(self.ownerType, privacy: .public) State: \(self.state.debugDescription, privacy: .public) -> \(newValue.debugDescription, privacy: .public)")
|
||||
}
|
||||
}
|
||||
|
||||
init(delegate: any TimelineLikeControllerDelegate<Item>) {
|
||||
init(delegate: any TimelineLikeControllerDelegate<Item>, ownerType: String) {
|
||||
self.delegate = delegate
|
||||
self.ownerType = ownerType
|
||||
}
|
||||
|
||||
func loadInitial() async {
|
||||
|
@ -171,7 +173,7 @@ class TimelineLikeController<Item: Sendable> {
|
|||
|
||||
private func emit(event: Event) async {
|
||||
guard state.canEmit(event: event) else {
|
||||
logger.error("State \(self.state.debugDescription, privacy: .public) cannot emit event: \(event.debugDescription, privacy: .public)")
|
||||
logger.error("\(self.ownerType, privacy: .public) State \(self.state.debugDescription, privacy: .public) cannot emit event: \(event.debugDescription, privacy: .public)")
|
||||
fatalError("State \(state) cannot emit event: \(event)")
|
||||
}
|
||||
switch event {
|
||||
|
@ -324,7 +326,7 @@ class TimelineLikeController<Item: Sendable> {
|
|||
case .loadAllError(let error, let token):
|
||||
return "loadAllError(\(error), \(token))"
|
||||
case .replaceAllItems(_, let token):
|
||||
return "replcaeAllItems(<omitted>, \(token))"
|
||||
return "replaceAllItems(<omitted>, \(token))"
|
||||
case .loadNewerError(let error, let token):
|
||||
return "loadNewerError(\(error), \(token))"
|
||||
case .prependItems(_, let token):
|
||||
|
|
Loading…
Reference in New Issue