{"id":18739726,"url":"https://github.com/roblabs/mapview-log-extensions","last_synced_at":"2025-11-19T15:30:15.213Z","repository":{"id":136165269,"uuid":"376995888","full_name":"roblabs/mapview-log-extensions","owner":"roblabs","description":"Opinionated logging of `mapView` events for MapKit, Mapbox \u0026 MapLibre.  Measure in Xcode console or Xcode Instruments.","archived":false,"fork":false,"pushed_at":"2022-01-30T00:01:34.000Z","size":3890,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-14T06:14:59.235Z","etag":null,"topics":["docc","mapbox","mapkit","maplibre","swift","xcode-instruments"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/roblabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2021-06-15T00:57:37.000Z","updated_at":"2023-04-15T09:19:03.000Z","dependencies_parsed_at":"2023-12-07T21:15:10.453Z","dependency_job_id":null,"html_url":"https://github.com/roblabs/mapview-log-extensions","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roblabs%2Fmapview-log-extensions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roblabs%2Fmapview-log-extensions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roblabs%2Fmapview-log-extensions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roblabs%2Fmapview-log-extensions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/roblabs","download_url":"https://codeload.github.com/roblabs/mapview-log-extensions/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239619570,"owners_count":19669447,"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":["docc","mapbox","mapkit","maplibre","swift","xcode-instruments"],"created_at":"2024-11-07T15:37:09.440Z","updated_at":"2025-11-19T15:30:15.100Z","avatar_url":"https://github.com/roblabs.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ``MapViewOSLogExtensions``\n\nOpinionated Swift logging of map view events for [MapKit](https://developer.apple.com/documentation/mapkit/mkmapviewdelegate), [Mapbox](https://docs.mapbox.com/ios/maps/api/6.3.0/Protocols/MGLMapViewDelegate.html) \u0026 [MapLibre](https://github.com/maplibre/maplibre-gl-native/blob/master/platform/ios/platform/macos/src/MGLMapViewDelegate.h).  Plays well with Xcode Instruments for millisecond timing of events.\n\n## Overview\n\nMeasure map view events such as `DidFinishLoadingStyle`, `DidFinishRenderingMap`, \u0026 `DidBecomeIdle` using `OSLog` and `os.signpost`.\n\n## Topics\n\n### How to Use\n\n#### 1.  Add the package via the Swift Package Manager.\n\n![Add the package via the Swift Package Manager.](Sources/MapViewOSLogExtensions/MapViewOSLogExtensions.docc/Swift-Packages~dark@2x.png)\n\n\n#### 2.  Add Opinionated Logs for map view.\n\nSee the enumeration ``mapEvents`` for suggested strings for your logs.\n\n```swift\nimport OSLog\nimport MapViewOSLogExtensions\n\nfunc beginMeasurementInterval() {\n  // Construct the map view object\n  OSLog.mapView(.begin, \"measure some event\")\n}\n\nfunc setZoomLevel(_ zoomLevel: Double) {\n    // Logs to Xcode console \u0026 Xcode Instruments\n    OSLog.mapView(.event, \"zoomLevel: \\(zoomLevel)\")\n    mapView.zoomLevel = zoomLevel\n}\n\nfunc endMeasurementInterval() {\n  // This could be in an event handlers\n  OSLog.mapView(.end, \"measure some event\")\n}\n```\n\n---\n\n## Xcode Instruments\n\nUse Xcode Instruments for filtering logs and measuring event intervals.  For more information on Xcode Instruments \u0026 signposts, see [Measuring Performance Using Logging](https://developer.apple.com/videos/play/wwdc2018/405/) from WWDC 2018.\n\n*Xcode Instruments with the Logging template selected.*\n\n![Xcode Instruments with the Logging template selected.](Sources/MapViewOSLogExtensions/MapViewOSLogExtensions.docc/Instruments-Logging~dark@2x.png)\n\n---\n\n## Filter Logs 🦮\n\nIf you use the opinionated log strings, such as `OSLog.mapEvents.DidFinishLoadingMap`, then you filter the Instruments data by using the filter `mapview`.  Through empirical testing, for Mapbox flavored SDKs the log analysis shows that map view events occur in this order, with `DidFinishLoadingMap` likely the event of when the map is displayed for the user.\n\n```console\n00:00.286.828\t[com.roblabs.log-mapview] Coordinator init, init(_:), line: 54\n00:00.288.457\t[com.roblabs.log-mapview] 🦮100. WillStartLoadingMap, mapViewWillStartLoadingMap(_:), line: 59\n00:00.292.670\t[com.roblabs.log-mapview] 🦮1. WillStartRenderingMap, mapViewWillStartRenderingMap(_:), line: 63\n00:00.321.970\t[com.roblabs.log-mapview] 🦮2. DidFinishLoadingStyle, mapView(_:didFinishLoading:), line: 67\n00:00.531.795\t[com.roblabs.log-mapview] 🦮3. DidFinishRenderingMap, mapViewDidFinishRenderingMap(_:fullyRendered:), line: 71\n00:00.531.982\t[com.roblabs.log-mapview] 🦮4. DidFinishLoadingMap, mapViewDidFinishLoadingMap(_:), line: 75\n00:01.129.784\t[com.roblabs.log-mapview] 🦮5. DidBecomeIdle, mapViewDidBecomeIdle(_:), line: 79\n```\n---\n\n## Results 📈\n\nSample data from five runs of [Geography Class](https://github.com/roblabs/openmaptiles-ios-demo) on a Simulator.  This sample project is making use of the `OSLog` extensions for map views.\n\n| Event `DidFinishLoadingMap` (msec)\n| :-------------\n| 531\n| 499\n| 500\n| 529\n| 514\n| **mean = 514**\n\n### Log vs. Signpost\n\n*Logging template with `os_log` and set input filter by a string.*\n\u003e Making observations on the data, the first entry is for 381 milliseconds, and the first entry for `DidBecomeIdle` is at 1258 milliseconds.  The event `DidFinishLoadingMap` was at 651 milliseconds.  Screen recording of the simulator or device can be useful to show when the map is shown to the customer.\n![Logging template with `os_log` and set input filter by a string.](Sources/MapViewOSLogExtensions/MapViewOSLogExtensions.docc/os_log-Geography-Class~dark@2x.png)\n\n---\n\n*Logging template with `os_signpost` and input filter set to filter by the name of the subsystem.*\n\u003e This view of the `os_signpost` shows that the first entry is for `DidBecomeIdle` is at 1258 milliseconds.  The event `DidFinishLoadingMap` was at 651 milliseconds.  Screen recording of the simulator or device can be useful to show when the map is shown to the customer.  The event `WillStartLoadingMap` started at 401 milliseconds, or about 850 milliseconds.  There is also a second `DidBecomeIdle` event occuring several seconds later.\n![Logging template with `os_signpost` and input filter set to filter by the name of the subsystem.](Sources/MapViewOSLogExtensions/MapViewOSLogExtensions.docc/os_signpost-Geography-Class~dark@2x.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froblabs%2Fmapview-log-extensions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Froblabs%2Fmapview-log-extensions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froblabs%2Fmapview-log-extensions/lists"}