{"id":19653559,"url":"https://github.com/sematext/sematext-logsene-ios","last_synced_at":"2025-06-11T19:33:12.163Z","repository":{"id":46089816,"uuid":"55164474","full_name":"sematext/sematext-logsene-ios","owner":"sematext","description":"Sematext Logs Client Library for iOS","archived":false,"fork":false,"pushed_at":"2024-06-24T15:58:08.000Z","size":1633,"stargazers_count":7,"open_issues_count":0,"forks_count":13,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-05-17T09:03:27.388Z","etag":null,"topics":["ios","log","log-management","logging","mobile-analytics","monitoring"],"latest_commit_sha":null,"homepage":"https://sematext.com/logsene","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sematext.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2016-03-31T16:07:23.000Z","updated_at":"2024-06-24T15:58:12.000Z","dependencies_parsed_at":"2025-04-28T17:49:31.022Z","dependency_job_id":null,"html_url":"https://github.com/sematext/sematext-logsene-ios","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/sematext/sematext-logsene-ios","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sematext%2Fsematext-logsene-ios","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sematext%2Fsematext-logsene-ios/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sematext%2Fsematext-logsene-ios/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sematext%2Fsematext-logsene-ios/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sematext","download_url":"https://codeload.github.com/sematext/sematext-logsene-ios/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sematext%2Fsematext-logsene-ios/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259325244,"owners_count":22841050,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ios","log","log-management","logging","mobile-analytics","monitoring"],"created_at":"2024-11-11T15:14:30.144Z","updated_at":"2025-06-11T19:33:12.142Z","avatar_url":"https://github.com/sematext.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"[logsene]: https://sematext.com/logsene/\n[register]: https://apps.sematext.com/ui/registration\n[hosted-kibana]: https://sematext.com/docs/logs/kibana/\n[video-tutorials]: https://www.elastic.co/blog/kibana-4-video-tutorials-part-1\n\nSDK for Shipping iOS Application Logs to Sematext\n=============================\n\n[![CI Status](http://img.shields.io/travis/sematext/sematext-logsene-ios.svg?style=flat)](https://travis-ci.org/sematext/sematext-logsene-ios)\n[![Version](https://img.shields.io/cocoapods/v/Logsene.svg?style=flat)](http://cocoapods.org/pods/Logsene)\n[![License](https://img.shields.io/cocoapods/l/Logsene.svg?style=flat)](http://cocoapods.org/pods/Logsene)\n[![Platform](https://img.shields.io/cocoapods/p/Logsene.svg?style=flat)](http://cocoapods.org/pods/Logsene)\n\n[Sematext Logs is ELK as a Service][logsene]. This library lets you collect **mobile analytics** and **log data** from your **iOS and WatchOS** applications using Sematext. There is an equivalent library for [shipping logs from Android](https://github.com/sematext/sematext-logsene-android) available. If you don't have a Sematext account, you can [register for free][register] to get your App token.\n\nUse the **Mobile Application Logs** Integration to get out-of-the-box reports with the most important information about your mobile applications.\n\nGet an overview of your mobile apps with information like:\n - top iOS and WatchOS versions\n - top log severity and version names\n\n![Mobile Logpack Overview](images/mobile_overview.png)\n\nExplore the common errors associated with your mobile applications and see an aggregated error view including:\n - number of errors and theirs count over time\n - top operating systems, top iOS and WatchOS versions that are reporting errors\n - error log events\n\n![Mobile Logpack Errors](images/mobile_errors.png)\n\nGet insights from dedicated iOS / WatchOS reports that include:\n - mobile operating system logs count histogram and their count\n - top severity, versions, version codes, and version names\n - mobile applications log events\n\n![Mobile Logpack iOS](images/mobile_ios.png)\n\nGetting Started\n---------------\n\n1. Logsene log shipping library for iOS and WatchOS is available through [CocoaPods](http://cocoapods.org). To install it, simply add the following line to your Podfile:\n\n```ruby\npod \"Logsene\"\n```\n\n2. Run `pod install`\n3. Call `LogseneInit()` from your application delegate in `didFinishLaunchingWithOptions:`. For example:\n\n```swift\n@UIApplicationMain\nclass AppDelegate: UIResponder, UIApplicationDelegate {\n    var window: UIWindow?\n\n    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -\u003e Bool {\n        try! LogseneInit(\"\u003cyourtoken\u003e\", type: \"example\")\n    }\n}\n```\n\nAdditional options are available:\n - the `receiverUrl` parameter allows specifying the data reciver if you are using our EU location\n - the `automaticLocationEnriching` parameter enabled automatic enrichment of logs from the mobile application with location data\n- offline storage size can be configured by using the `maxOfflineFileSize` (100000 by default) and `maxOfflineFiles` (10 by default) parameters. The size of the offline storage will be equal to `maxOfflineFileSize` multiplied by `maxOfflineFiles`.\n\n**Note**: We highly recommend creating a write-only token in your application settings for use in your mobile apps.\n\nExample Application\n-------------------\n\nYou can try out the example application with Cocoapods:\n\n```bash\ncd ~/Desktop\npod try Logsene\n```\n\nMake sure to set your own application token in `AppDelegate.swift`.\n\nMobile Application Analytics\n----------------------------\n\nYou can collect application analytics using Sematext. To do that, use the `LLogEvent()` function to send custom events. For example, you might want to send an event each time the user completes a game level:\n\n```swift\nLLogEvent([\"event\": \"level_completed\", \"message\": \"Level 3 completed\", \"value\": \"3\"])\n```\n\nTo visualize the collected data use [Sematext dashboards](https://sematext.com/docs/dashboards/).\n\nIf you don't see the events in the dashboard immediately, note that this library sends data in batches to preserve the battery (every 60s), or if there are more than 10 messages queued up. Messages are saved while the device is offline, so you don't have to worry about losing any data.\n\nWhen it comes to the structure of your events, you are free to choose your own, the above is just an example. You can use any number of fields, and you can use nested fields. Basically, any valid JSON object will work fine. Note that the library reserves the `meta` field for meta information (see below). If you set a value for this field when sending an event, no meta information will be included for that event.\n\nMeta Fields\n-----------\n\nA few predefined meta fields are included in each event sent to Sematext. The fields are stored inside the \"meta\" field.\n\n- versionName (app version string, eg. 1.0)\n- versionCode (app build number, eg. 92)\n- osRelease (iOS or WatchOS version, eg. 9.3.0)\n- uuid (device identifier)\n- OS type (iOS or WatchOS)\n\nYou can set your own meta fields with `LogseneSetDefaultMeta`. For example:\n\n```swift\nLogseneSetDefaultMeta([\"user\": \"user@example.com\", \"plan\": \"free\"])\n```\n\nNote that these meta fields are global, and will be attached to every event sent to Logsene.\n\nPausing \u0026 Resuming Logs Sending\n----------------------------------------\n\nThe library can be instructed to stop sending logs on demand. To do that you need to call the following function:\n\n```swift\nLogsenePauseSendingLogs()\n```\n\nLogs sending can be resumed by calling the following function:\n\n```swift\nLogseneResumeSendingLogs()\n```\n\nNote that the logs that are in the buffer and were waiting to be sent at the time of pausing will not be sent until the logs sending process is resumed. \n\nCentralized Logging\n-------------------\n\nThe library offers some basic functions for centralized logging:\n\n- LLogDebug\n- LLogInfo\n- LLogWarn\n- LLogError\n\nEach function provides two variants - logging a message or error without and with the device location. \n\nExample of writing a log message:\n\n```swift\nDDLogInfo(\"hello world!\")\n```\n\nExample of writing a log message with location data:\n\n```swift\nlet location = LogsLocation(fromLatitude: 53.13, fromLongitude: 23.16)\nLLogInfo(withMessage: \"hello world with location!\", withLocation: location)\n```\n\n#### Automatically enrich logs with location data on iOS and WatchOS\n\nIf you would like to allow the library to automatically enrich log data with the location data it is as easy as properly initializing the library, for example:\n\n```swift\nLogseneInit(\"\u003cyourtoken\u003e\", type: \"example\", automaticLocationEnriching: true, useLocationOnlyInForeground: true)\n```\n\nThere are two properties here:\n * **automaticLocationEnriching** - when set to true the library will try to enrich the logs with location information,\n * **useLocationOnlyInForeground** - when set to true the location will only be gathered when the application is in forground.\n \n In addition to setting up the **LogseneInit** properly you also need to ensure to include two additonal string values in the **Info.plist** file that will be diplayed when asking the user to allow location data to be gathered. Those aree:\n * **Privacy - Location Always and When In Use Usage Description** \n * **Privacy - Location When In Use Usage Description**\n\n**Automatic location enriching only works with iOS and WatchOS, not MacOS.** \n\nFor integrating with existing logging frameworks, see below.\n\n### CocoaLumberjack\n\nIf you're using CocoaLumberjack for logging, you can use the custom Logsene logger to send log messages to Sematext automatically. You should configure CocoaLumberjack to use the Logsene logger:\n\n```swift\n@UIApplicationMain\nclass AppDelegate: UIResponder, UIApplicationDelegate {\n    var window: UIWindow?\n\n    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -\u003e Bool {\n        // NOTE: Set your token below\n        try! LogseneInit(\"\u003cyourtoken\u003e\", type: \"example\")\n\n        // Here we setup CocoaLumberjack to log to both XCode console and Logsene\n        DDLog.addLogger(DDTTYLogger.sharedInstance())\n        DDLog.addLogger(LogseneLogger())\n        DDLogInfo(\"hello world from CocoaLumberjack!\")\n        return true\n    }\n}\n```\n\nLogseneLogger is not included in the pod, but you can find the [implementation here](Example/Logsene/Logger.swift). Feel free to use it in your own project.\n\n### How to log unhandled exceptions\n\nYou can log any unhandled Foundation exceptions by defining your own uncaught exception handler. For example:\n\n```swift\n@UIApplicationMain\nclass AppDelegate: UIResponder, UIApplicationDelegate {\n    var window: UIWindow?\n\n    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -\u003e Bool {\n        // NOTE: Set your token below\n        try! LogseneInit(\"\u003cyourtoken\u003e\", type: \"example\")\n\n        NSSetUncaughtExceptionHandler { exception in\n            // log unhandled exception message\n            LLogError(exception)\n        }\n        return true\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsematext%2Fsematext-logsene-ios","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsematext%2Fsematext-logsene-ios","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsematext%2Fsematext-logsene-ios/lists"}