https://github.com/stanwood/harlow
ヽ༼ಠل͜ಠ༽ノ Harlow is an advanced iOS In App logging & debugging 🐛 framework written in Swift, with comprehensive logs for Analytics, Networking, Errors, Crashes and Print logs
https://github.com/stanwood/harlow
analytics analytics-logging analytics-tracking error-monitoring error-reporting ios logger logging logging-framework logging-library network network-analysis network-monitoring swift swift4
Last synced: 7 months ago
JSON representation
ヽ༼ಠل͜ಠ༽ノ Harlow is an advanced iOS In App logging & debugging 🐛 framework written in Swift, with comprehensive logs for Analytics, Networking, Errors, Crashes and Print logs
- Host: GitHub
- URL: https://github.com/stanwood/harlow
- Owner: stanwood
- License: mit
- Created: 2018-03-12T12:36:19.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-04-06T13:45:34.000Z (over 4 years ago)
- Last Synced: 2025-04-10T00:03:25.675Z (7 months ago)
- Topics: analytics, analytics-logging, analytics-tracking, error-monitoring, error-reporting, ios, logger, logging, logging-framework, logging-library, network, network-analysis, network-monitoring, swift, swift4
- Language: Swift
- Homepage:
- Size: 73.2 MB
- Stars: 8
- Watchers: 4
- Forks: 4
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README

[]()
[]() [](https://codeclimate.com/github/stanwood/Harlow/maintainability)
[](https://travis-ci.org/stanwood/Harlow)
Debugging and testing iOS applications can be quite a long task due to the nature of Software Development. _Harlow_ tool provides reach information on Analytics, Errors, Logging, Networking, and UITesting to simplify this process.
[]()
## Table of contents
- [Author](#author)
- [Installation](#installation)
- [Usage](#usage)
- [Licence](#licence)
- [Changelog](#changelog)
## Author
Tal Zion tal.zion@stanwood.io
## Installation
```ruby
pod 'Harlow', :configurations => ['Debug'] # Make sure to only use Harlow for development only.
```
## Usage
```swift
#if DEBUG
import Harlow
#endif
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
#if DEBUG
lazy var debugger: Harlow = Harlow()
#endif
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
#if DEBUG
debugger.isEnabled = true
#endif
}
}
```
### Other options
```swift
debugger.isDebuggingDataPersistenceEneabled = true /// Enables local data persistance
debugger.enabledServices: [Service] = [.logs, .errors] /// The services you would like to enable. Default is se to `allCases`
debugger.tintColor = .red /// Change the tint color
debugger.errorCodesExceptions = [4097] /// Add error code exceptions
debugger.isShakeEnabled = true // Defaults to `true`. When this is `true`, shaking the device will enable/disable the Debugger
debugger.isEnabled = true
```
## Adding logs
### Analytics
##### Option 1.
Set up your tracking payload:
```swift
public func payload() -> [String:String] {
var payload: [String:String] = ["eventName": eventName]
if let itemId = itemId {
payload["itemId"] = itemId
}
if let category = category {
payload["category"] = category
}
if let contentType = contentType {
payload["contentType"] = contentType
}
if let screenName = screenName {
payload["screenName"] = screenName
}
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZ"
payload["createdAt"] = dateFormatter.string(from: Date())
return payload
}
```
Post it to:
```swift
func post(_ payload: [String:String]) {
let notificationCentre = NotificationCenter.default
let notification = Notification.init(name: Notification.Name(rawValue: "io.stanwood.debugger.didReceiveAnalyticsItem"), object: nil, userInfo: payload)
notificationCentre.post(notification)
}
```
##### Option 2.
Use [StanwoodAnalytics](https://github.com/stanwood/Stanwood_Analytics_iOS) as your tracking framework
```swift
#if DEBUG
analyticsBuilder = analyticsBuilder.setDebuggerNotifications(enabled: true)
#endif
```
### Networking
`Harlow` works by default with `URLSessiosn.shared` and request are beeing logged for free. You can also register a custom condiguration:
```swift
let configuration = URLSessionConfiguration.waitsForConnectivity
debugger.regsiter(custom: configuration)
/// Use with URLSession || any networking libraries such as Alamofire and Moya
let session = URLSession(configuration: configuration)
```

### Error
`Harlow` will log `NSError` by default. To add log exceptions:
```swift
debugger.errorCodesExceptions = [4097] /// Add error code exceptions
```
### Logs
`Harlow` will log `print` && `debugPrint` by default.
#### Configuration:
1. Create a new `Bridging-Header` file and add `-DEBUG` suffix

2. Import `Harlow`
```objc
@import Harlow;
```
>Note: Make sure to add any other imported libraries from your main header file
3. Set `Bridging-Header-DEBUG.h` in the relevant configurations in the build settings.

### Crashes
`Harlow` will log `Signal` and `NSException` crashes by default.
## Licence
Harlow is under MIT licence. See the [LICENSE](https://github.com/stanwood/Harlow/blob/master/LICENSE.md) file for more info.
## Changelog
A brief summary of each Harlow release can be found in the [CHANGELOG](https://github.com/stanwood/Harlow/blob/master/CHANGELOG.md).