Skip to content

UILogger is a simple logging framework and cocoapod for UI actions on iOS

License

Notifications You must be signed in to change notification settings

truemetal/ios-ui-logger

Repository files navigation

UILogger

CI Status Version License Platform

Did you ever have a need to add logging of user actions to see how to reproduce that crash? This pod does just that.

UILogger.printToConsole = false

NotificationCenter.default.addObserver(forName: UILogger.uiLogNotification, object: nil, queue: nil) { (n) in
    guard let logItem = n.object as? UILogItem else { return }
    // do something here with logItem
    print("received log item: \(UILoggerLaunchTimeHolder.appUptime()) \(logItem.descriptionDict)")
}

At this point n.object is an instance of one of the subclasses of UILogItem. Each of the subclasses store action details in properties (please feel free to take a look at those), also each subclass implements this property, which contains all details as strings:

public lazy var descriptionDict: [String : String]

Action types

There're these log action types: viewControllerDidAppear, controlAction, tableCellTap and collectionCellTap

Under the hood there's swift code for the logic and obj-c code that swizzles UIApplication, UIViewController, UITableView and UICollectionView. Please let me know if you have a better idea for implementing this then swizzling.

Cell title customization

There's this protocol if you'd like to return title from custom table or collection view cell:

public protocol UILogTitleProvider {
    var uiLogTitle: String? { get }
}

Example

To run the example project, clone the repo and open the workspace from the Example dir.

demo

Installation

UILogger is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'UILogger'

Author

Dan Pashchenko
https://ios-engineer.com

License

UILogger is available under the MIT license. See the LICENSE file for more info.

About

UILogger is a simple logging framework and cocoapod for UI actions on iOS

Resources

License

Stars

Watchers

Forks

Packages

No packages published