{"id":31144247,"url":"https://github.com/outfoxx/oslogtrace","last_synced_at":"2026-02-26T08:41:30.417Z","repository":{"id":63919627,"uuid":"162923323","full_name":"outfoxx/OSLogTrace","owner":"outfoxx","description":"📒 OSLogTrace - Apple System Logging, Signposts \u0026 Activity Tracing","archived":false,"fork":false,"pushed_at":"2019-12-01T05:00:21.000Z","size":19,"stargazers_count":10,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-28T12:27:38.934Z","etag":null,"topics":["ios","log","logging","macos","swift","tvos","watchos"],"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/outfoxx.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}},"created_at":"2018-12-23T20:54:52.000Z","updated_at":"2024-09-23T11:29:25.000Z","dependencies_parsed_at":"2023-01-14T14:00:51.074Z","dependency_job_id":null,"html_url":"https://github.com/outfoxx/OSLogTrace","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/outfoxx/OSLogTrace","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/outfoxx%2FOSLogTrace","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/outfoxx%2FOSLogTrace/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/outfoxx%2FOSLogTrace/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/outfoxx%2FOSLogTrace/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/outfoxx","download_url":"https://codeload.github.com/outfoxx/OSLogTrace/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/outfoxx%2FOSLogTrace/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275781929,"owners_count":25527490,"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","status":"online","status_checked_at":"2025-09-18T02:00:09.552Z","response_time":77,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","logging","macos","swift","tvos","watchos"],"created_at":"2025-09-18T14:37:57.336Z","updated_at":"2025-09-18T14:37:58.479Z","avatar_url":"https://github.com/outfoxx.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 📒OSLogTrace\n[![Build Status](https://travis-ci.org/outfoxx/OSLogTrace.svg?branch=master)](https://travis-ci.org/outfoxx/OSLogTrace)\n![GitHub release (latest by date)](https://img.shields.io/github/v/release/outfoxx/oslogtrace)\n## API for Apple's System Log, Signposts and Activty tracing built for Swift\nThe framework uses features introduced in Swift 5 to make interacting with Apple system log natural and easy from Swift code. Swift\noriented convenience APIs for logging signposts and activity tracing are also included to make their use natural as well.\n\n## Logging\n\n### OSLogManager\n\nThe log manager, `OSLogManager`, is a factory to vend configured `OSLog` instances.\n\nUse by calling the static `for` method to create an instance of `OSLogManager`:\n```swift\nlet log = OSLogManager.for(category: \"My Application\")\n```\n\nFurther configuration can be achieved by providing a configuration block to alter the manager's properties:\n```swift\nlet logManager = OSLogManager.for(category: \"My Application\") { logManager in\n  logManager.baseCategory = \"General\"\n}\n```\n\n`OSLogManager` \u0026 `OSLog` provide prefixes that can be used to help identify log messages in complex output. The default values use emoji to \nuniquely identify each log level.  For customization, application-wide configuration of logging prefixes can be done using the global\nvariable `logConfig`:\n```swift\nOSLogTrace.logConfig.prefix.error = \"☢️\"\n```\n\n### OSLog\n\nThe logging interface uses the standard `OSLog`  class provided by the `os.log` package. It is extended with typed methods for each log level and\ntake a `LogMessage` to provide parameterized logging messages using Swift 5's string interpolation magic.\n\n```swift\nextension OSLog {\n  public func log(type: OSLogType, _ message: @autoclosure () -\u003e LogMessage)\n  public func log(_ message: @autoclosure () -\u003e LogMessage) \n  public func info(_ message: @autoclosure () -\u003e LogMessage)\n  public func debug(_ message: @autoclosure () -\u003e LogMessage)\n  public func error(_ message: @autoclosure () -\u003e LogMessage)\n  public func fault(_ message: @autoclosure () -\u003e LogMessage)\n}\n```\n\n### LogMessage\n\nGenerating parameterized log messages is simple using `LogMessage` and thanks to Swift 5's string interpolation support\n(via `ExpressibleByStringInterpolation`) they can be created using standard Swift syntax...\n\n```swift\nlet audience = \"World\"\nlog.info(\"Hello \\(audience)\")\n```\n\nThis simple log message properly passes the `audience` parameter on to the `OSLog` as a _dynamic parameter_. This defers\nmessage creation until needed and allows us to control how the system log displays and reports these parameters.\n\n##### Display\n\nApple's system log can interpret certain types of data and OSLogTrace's logging extensions expose that capability naturally.\n\nFor example, if you are logging download progress you might use:\n```swift\nlet completedBytes = 2.4 * 1024 * 1024\nlog.debug(\"Downloaded \\(completedBytes, unit: .bytes)\")\n```\n\nThe log will display the value using the best available unit. In this specfic case it would be reported as:\n    \n    Downloaded 2.4 MiB \n\n##### Privacy\n\nApple's System Log supports privacy as well.  Marking parameters as `private` will ensure this information is not stored long term and redacted in\nthe right context.\n\nFor example, logging a sign-in that contains a private email address is simple:\n```swift\nlet accountEmail = \"test@example.com\"\nlog.info(\"Sign-in from \\(accountEmail, view: .private)\")\n```\n\nThe system log will now take care of handling the sensitive email data.\n\nFor more information see \"Formmatting Log Messages\" in\n[Apple's Logging documentation](https://developer.apple.com/documentation/os/logging#topics)\n\n### Signposts\n\nSignpost's are Apple's logging enhancement for debugging and profiling working side-by-side with `OSLog`. Signpost IDs can be\ncreated and marked using OSLogTrace's convenience API(s).\n\nCreate a signpost ID unique to a specific log instance, and mark it:\n```swift\nlet log: OSLog = ...\nlet spid = log.signpostID()  // Create ID\nlog.event(\"Stage 1\", spid)   // Mark \"event\"\nlog.event(\"Stage 1\", spid, \"A \\(parameterized) message\") // Mark \"event\" with a log message\n```\n\nUtilize the `Signpost` convenience API to manage a signpost ID and log together:\n```swift\nlet log: OSLog = ...\nlet sp = log.signpost()   // Create a Signpost with a unique signpost ID\nsp.event(\"Stage 1\")       // Mark \"event\"\nsp.event(\"Stage 1\", \"A \\(parameterized) message\") // Mark \"event\" with a log message\n```\n\n\n## Activity Tracing\n\nOSLogTrace also provides a convenience API for Apple's activity tracing.\n\nCreate an `Activity` and immediately execute code in its context:\n```swift\nActivity(\"Download Email\") {\n  // download the emails\n}\n```\n\nCreate an `Activity` and execute multiple code blocks in its context:\n```swift\nlet emailDownload = Activity(\"Download Email\")\n\nemailDownload.run {\n  // download some emails\n}\n\n...\n\nemailDownload.run {\n  // download some emails\n}\n```\n\nCreate an `Activity` and manually manage the entering and leaving of its scope/context:\n```swift\nlet emailDownload = Activity(\"Download Email\")\n\nlet scope = emailDownload.enter()\ndefer { scope.leave() }\n\n// download some emails\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foutfoxx%2Foslogtrace","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foutfoxx%2Foslogtrace","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foutfoxx%2Foslogtrace/lists"}