{"id":16482774,"url":"https://github.com/shaps80/logging","last_synced_at":"2025-03-21T07:30:49.656Z","repository":{"id":46708582,"uuid":"408380756","full_name":"shaps80/Logging","owner":"shaps80","description":"Apple's SwiftLog + OSLog style StringInterpolation","archived":false,"fork":false,"pushed_at":"2024-07-22T11:58:40.000Z","size":45,"stargazers_count":19,"open_issues_count":0,"forks_count":5,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-17T22:28:16.099Z","etag":null,"topics":["logging","swift"],"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/shaps80.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}},"created_at":"2021-09-20T09:21:45.000Z","updated_at":"2025-03-01T17:06:38.000Z","dependencies_parsed_at":"2024-01-29T12:15:39.462Z","dependency_job_id":"73ad8dcc-b30c-4c61-b7e7-27737289063f","html_url":"https://github.com/shaps80/Logging","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shaps80%2FLogging","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shaps80%2FLogging/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shaps80%2FLogging/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shaps80%2FLogging/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shaps80","download_url":"https://codeload.github.com/shaps80/Logging/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244757296,"owners_count":20505367,"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":["logging","swift"],"created_at":"2024-10-11T13:12:01.031Z","updated_at":"2025-03-21T07:30:49.298Z","avatar_url":"https://github.com/shaps80.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"![ios](https://img.shields.io/badge/iOS-13-green)\n![tv](https://img.shields.io/badge/tvOS-13-green)\n![watch](https://img.shields.io/badge/watchOS-6-green)\n![mac](https://img.shields.io/badge/macOS-10.15-green)\n\n# Logging\n\nA version of Apple's [SwiftLog](https://github.com/apple/swift-log) that adds some improved formatting for app development and includes OSLog-ish string interpolation.\n\n__Feature List__\n\n- [x] ~~Privacy (public, private and masked)~~\n- [x] ~~Log levels~~\n- [x] ~~FormattedLogHandler~~\n- [x] ~~Literal string~~\n- [x] ~~Numerical formats~~\n- [x] ~~Boolean formats~~\n- [ ] Exponential formats\n- [ ] Hexadecimal formats\n- [ ] Column formatting\n\n\u003e I've also added many tests to ensure the string interpolation and privacy features are working as expected. However, I have not included any of SwiftLog's tests since the library is simply a _direct copy_ (see below).\n\n## Examples\n\n```swift\n// Somewhere in your code, define your log handler(s)\nLoggingSystem.bootstrap { label in \n    FormattedLogHandler(label: label)\n}\n\n// Then in a framework or subsystem, define a logger\nlet logger = Logger(label: \"com.benkau.logging\")\nlogger.debug(\"Hello, world!\")\n```\n\nSimilar to OSLog, all interpolated values default to a `private` scope (in a non-`DEBUG`) environment, with their values redacted.\n\n```swift\nlogger.debug(\"Logged in as \\(user, privacy: .private)\")\n// Logged in as \u003credacted\u003e\n\nlogger.debug(\"Fetching data from \\(url, privacy: .private(.hash))\")\n// Fetching data from 210237823\n```\n\nThere are conveniences for logging numerical values:\n\n```swift\nlogger.debug(\"Pi is \\(3.14159265359, format: .fixed(precision: 2))\")\n// Pi is 3.14\n\nlogger.debug(\"Current score: \\(score, format: .decimal(minDigits: 2)\")\n// Current score: 03\n```\n\n## Formatting\n\nThe library includes a custom `FormattedLogHandler` that you're free to use or create your own. The provided handler uses SFSymbols to improve readability and clarity in the console, as well as providing a simple closure based formatter so you can make it your own.\n\n```swift\nFormattedLogHandler { options in \n    // simply return your formatted log\n    FormattedLogHandler(label: label) { data in\n        \"\\(data.timestamp()) [\\(data.label)] \\(data.level.symbol) \\(data.message)\"\n    }\n}\n```\n\n\u003e Obviously you can always use your own `LogHandler` as you can directly with SwiftLog.\n\n## SwiftLog\n\nThe actual logging framework is a _direct copy_ of Apple's own SwiftLog. The reason I didn't include it as a dependency is because there was no way for me to _extend_ it to include string interpolation that I could see. If anyone has ideas on how to make this work, I would love to hear about them. Please open an Issue so we can discuss it as this would allow me to properly attribute and pin to a dependency version etc...\n\n## Installation\n\nThe code is packaged as a framework. You can install manually (by copying the files in the `Sources` directory) or using Swift Package Manager (**preferred**)\n\nTo install using Swift Package Manager, add this to the `dependencies` section of your `Package.swift` file:\n\n`.package(url: \"https://github.com/shaps80/Logging.git\", .upToNextMinor(from: \"1.0.0\"))`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshaps80%2Flogging","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshaps80%2Flogging","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshaps80%2Flogging/lists"}