{"id":24805090,"url":"https://github.com/benrobinson16/applog","last_synced_at":"2025-09-10T19:37:26.625Z","repository":{"id":190383637,"uuid":"347235467","full_name":"benrobinson16/AppLog","owner":"benrobinson16","description":"Super simple logging for Swift.","archived":false,"fork":false,"pushed_at":"2021-03-13T14:37:50.000Z","size":27,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-25T08:11:11.243Z","etag":null,"topics":["diagnostics","log","logging","swift","swiftpackage"],"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/benrobinson16.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}},"created_at":"2021-03-13T00:39:16.000Z","updated_at":"2021-03-13T14:37:51.000Z","dependencies_parsed_at":"2023-08-24T12:25:22.509Z","dependency_job_id":null,"html_url":"https://github.com/benrobinson16/AppLog","commit_stats":null,"previous_names":["benrobinson16/applog"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/benrobinson16/AppLog","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benrobinson16%2FAppLog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benrobinson16%2FAppLog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benrobinson16%2FAppLog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benrobinson16%2FAppLog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/benrobinson16","download_url":"https://codeload.github.com/benrobinson16/AppLog/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benrobinson16%2FAppLog/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274512841,"owners_count":25299536,"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-10T02:00:12.551Z","response_time":83,"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":["diagnostics","log","logging","swift","swiftpackage"],"created_at":"2025-01-30T07:16:49.044Z","updated_at":"2025-09-10T19:37:26.564Z","avatar_url":"https://github.com/benrobinson16.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AppLog\n\nAppLog is a super simple logging package for Swift.\n\n## Installation\n\nAppLog is distributed as a Swift Package. To install:\n\n- For other Swift Packages: add the following to your `Package.swift` file:\n  ```swift\n  .package(name: \"AppLog\", url: \"https://github.com/benrobinson16/AppLog.git\", .upToNextMajor(from: .init(1, 0, 0)))\n  ```\n- For Xcode projects: use the GUI to add `https://github.com/benrobinson16/AppLog.git` to your dependencies. It is recommended to choose \"up to next major\" as the version requirement.\n\n## Making the instance\n\nFirst, make an instance of `AppLog` in your app. There can be multiple instances if necessary.\n\n```swift\nlet log = AppLog()\n```\n\nYou can also specify a custom file name if you would like to use multiple log files for different portions of the app:\n\n```swift\nlet log = AppLog(filename: \"error.txt\")\n```\n\nNote that the `filename` should include a `.txt` extension.\n\n## Reporting logs\n\nOnce you have your instance, simply use the `report` method to write a new log to the file:\n\n```swift\nlog.report(\"My test log\")\n```\n\nYou can use any of the available overloads (including providing an error) to report logs:\n\n```swift\nlog.report(\"My test log\")\nlog.report([\"My test log\", \"Second log\"])\nlog.report(\"My test log\", \"Second log\")\n\nlog.report(myError)\nlog.report([myError, myError2])\nlog.report(myError, myError2)\n```\n\nUsing any of the `String` overloads, defaults to the `.normal` severity. `Error` overloads default to the `.error` severity.\n\n\u003e Note that when logs are made, they are also printed to the console (i.e. no need for an extra `print` statement as well). However, in debug builds, AppLog will not print to the console.\n\n## Severity/formatting\n\nYou can optionally provide a severity level to apply to your log.\n\nThere are four available severity levels:\n\n- `.normal` - indicates a standard log\n- `.debug` - same format as `.normal` but is added only in debug builds\n- `.error` - standard error reporting; gives more prominence to the error\n- `.critical` - a major error that causes the app to crash or functionality to not work as intended\n\nHere are examples of each severity's output:\n\n```swift\nlog.report(\"My test log\", severity: .normal)\n\n// outputs...\n\n\u003cdate\u003e, \u003csender-file\u003e, \u003csender-function\u003e, \u003csender-line\u003e\nmy test log\n```\n```swift\nlog.report(\"My test log\", severity: .error)\n\n// outputs...\n\nERROR:\nmy test log\nDATE: \u003cdate\u003e\nSENDER: \u003csender-file\u003e, \u003csender-function\u003e, \u003csender-line\u003e\n```\n\n```swift\nlog.report(\"My test log\", severity: .critical)\n\n// outputs...\n\n--- CRITICAL ---\n\nmy test log\n\nDATE: \u003cdate\u003e\nSENDER-FILE: \u003csender-file\u003e\nSENDER-FUNCTION: \u003csender-function\u003e\nSENDER-LINE: \u003csender-line\u003e\n\nIMMEDIATE ACTION REQUIRED\n\n--- END CRITICAL ---\n```\n\n## Reading the file\n\nTo read the contents of the log file, simply use the `readFile()` method:\n\n```swift\nlet contents = log.readFile()\nif case .success(let str) = contents {\n    // Use file contents\n}\n```\n\nThe file contents can then be used during a feedback/bug report or similar.\n\n## Clearing the file\n\nOccasionally, it is a good idea to clear the file to prevent it from becoming too large. This can be acheived through the `clearFile()` method:\n\n```swift\nlog.clearFile()\n```\n\n## Credits/Legal\n\nSee `LICENSE.md` for more information.\n\nThis package was created by [benrobinson16](https://github.com/benrobinson16).\n\nCopyright (c) 2021 Benjamin Robinson. All Rights Reserved.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenrobinson16%2Fapplog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenrobinson16%2Fapplog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenrobinson16%2Fapplog/lists"}