UILogger 1.0.1

UILogger 1.0.1

测试已测试
lang语言 Obj-CObjective C
许可协议 MIT
发布上次发布2018年2月

Dan Pashchenko 维护。



UILogger 1.0.1

  • Dan Pashchenko

您是否曾经需要添加对用户操作的日志记录以便查看如何重现那种崩溃?这个 Pod 就能完成这个任务。

UILogHelper.printToConsole = false

NotificationCenter.default.addObserver(forName: UILogItem.uiLogNotification, object: nil, queue: nil) { n in
    // handle log event, e.g. add it to your crash reporter's
    guard let log = n.object as? UILogItem else { return }
    if log.type == .viewControllerDidAppear { }
    if log.type == .controlAction { }
}

此时n.objectUILogItem的实例,具有以下属性

@property (nonatomic) UILogItemType type;
@property (nonatomic, strong, nonnull) NSDate *timestamp;
@property (nonatomic, strong, nonnull) NSObject *object;
@property (nonatomic, strong, nullable) NSString *title;
@property (nonatomic, strong, nullable) NSIndexPath *indexPath;

这是一个相当简化的实现,如果您想添加功能请随时提出问题。一个 pull-request 会更好。

底层是用obj-c编写的代码,它通过 swizzling 对UIApplicationUIViewControllerUITableViewUICollectionView 进行操作。
如果对如何实现 swizzling 有更好的建议,请告诉我。

示例

要运行示例项目,请克隆仓库,并首先从 Example 目录中运行 pod install

安装

UILogger 通过 CocoaPods 提供。要安装
它,只需将以下行添加到 Podfile 中

pod 'UILogger'

安装

待办事项

  • 清理控制台日志逻辑
  • 创建 UILogTitle 协议及其对 UIViewControllerUIButtonUICollectionViewCell 的扩展,以便提供有意义的标题

作者

Dan Pashchenko https://ios-engineer.com

许可协议

UILogger 在 MIT 许可下提供。有关更多信息,请参阅 LICENSE 文件。