{"id":24064377,"url":"https://github.com/perseusrealdeal/consoleperseuslogger","last_synced_at":"2026-05-30T21:31:40.099Z","repository":{"id":258094039,"uuid":"866726851","full_name":"perseusrealdeal/ConsolePerseusLogger","owner":"perseusrealdeal","description":"Swift Logger lib. macOS 10.13+, iOS 11+, Xcode 14.2+.","archived":false,"fork":false,"pushed_at":"2024-12-02T20:42:54.000Z","size":33,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-09T10:25:17.029Z","etag":null,"topics":["person-to-person","swift-developer","swift-logger","swift-tool"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/perseusrealdeal.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2024-10-02T19:06:51.000Z","updated_at":"2024-11-09T16:35:39.000Z","dependencies_parsed_at":"2025-01-09T10:25:04.028Z","dependency_job_id":"45a1d709-4b8a-4fb3-939a-757baadf6163","html_url":"https://github.com/perseusrealdeal/ConsolePerseusLogger","commit_stats":null,"previous_names":["perseusrealdeal/consoleperseuslogger"],"tags_count":7,"template":false,"template_full_name":"perseusrealdeal/TheTechnologicalTree","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perseusrealdeal%2FConsolePerseusLogger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perseusrealdeal%2FConsolePerseusLogger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perseusrealdeal%2FConsolePerseusLogger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perseusrealdeal%2FConsolePerseusLogger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/perseusrealdeal","download_url":"https://codeload.github.com/perseusrealdeal/ConsolePerseusLogger/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240901017,"owners_count":19875634,"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":["person-to-person","swift-developer","swift-logger","swift-tool"],"created_at":"2025-01-09T10:24:57.482Z","updated_at":"2025-10-30T00:34:49.153Z","avatar_url":"https://github.com/perseusrealdeal.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ConsolePerseusLogger — Xcode 14.2+\n\n\u003e [`iOS approbation app`](https://github.com/perseusrealdeal/TheOneRing) [`macOS approbation app`](https://github.com/perseusrealdeal/Arkenstone)\n\n\u003e Light-weight logging lover in Swift. Hereinafter `CPL` stands for `C`onsole `P`erseus `L`ogger.\u003cbr/\u003e\n\n\u003e - Log to the console.\u003cbr/\u003e\n\u003e - Log to macOS Console.app.\u003cbr/\u003e\n\u003e - Log to custom output.\n\n\u003e `[TYPE] [DATE] [TIME] [PID:TID] message, file: #, line: #`\n\n\u003e `CPL` is a single author and personale solution developed in `person-to-person` relationship paradigm.\n\n[![Actions Status](https://github.com/perseusrealdeal/ConsolePerseusLogger/actions/workflows/main.yml/badge.svg)](https://github.com/perseusrealdeal/ConsolePerseusLogger/actions/workflows/main.yml)\n[![Style](https://github.com/perseusrealdeal/ConsolePerseusLogger/actions/workflows/swiftlint.yml/badge.svg)](https://github.com/perseusrealdeal/ConsolePerseusLogger/actions/workflows/swiftlint.yml)\n[![Version](https://img.shields.io/badge/Version-1.5.1-green.svg)](/CHANGELOG.md)\n[![Platforms](https://img.shields.io/badge/Platforms-macOS%2010.13+_|_iOS%2011.0+-orange.svg)](https://en.wikipedia.org/wiki/List_of_Apple_products)\n[![Xcode 14.2](https://img.shields.io/badge/Xcode-14.2+-red.svg)](https://en.wikipedia.org/wiki/Xcode)\n[![Swift 5.7](https://img.shields.io/badge/Swift-5.7-red.svg)](https://www.swift.org)\n[![License](http://img.shields.io/:License-MIT-blue.svg)](/LICENSE)\n\n## Integration Capabilities\n\n[![Standalone](https://img.shields.io/badge/Standalone%20-available-informational.svg)](/CPLStar.swift)\n[![Swift Package Manager compatible](https://img.shields.io/badge/Swift%20Package%20Manager-compatible-4BC51D.svg)](/Package.swift)\n\n\u003e [!TIP]\n\u003e To adopt `CPL` for the specifics you need use [Standalone](/CPLStar.swift).\n\n## Approbation Matrix\n\n\u003e [`A3 Environment and Approbation`](/APPROBATION.md) / [`CHANGELOG`](/CHANGELOG.md) for details.\n\n\u003e Xcode playground [download page](https://github.com/PerseusRealDeal/ConsolePerseusLogger/issues/17).\n\n## In brief \u003e Idea to use\n\n\u003e USE LOGGER LIKE A VARIABLE ANYWHERE YOU WANT.\u003cbr/\u003e\n\n![Image](https://github.com/user-attachments/assets/d1bb43ab-1342-4dff-b4d4-0fbd205dba39)\n\n## Build requirements\n\n- [macOS Monterey 12.7.6+](https://apps.apple.com/by/app/macos-monterey/id1576738294) / [Xcode 14.2+](https://developer.apple.com/services-account/download?path=/Developer_Tools/Xcode_14.2/Xcode_14.2.xip)\n\n\u003e [!TIP]\n\u003e As the single source code [CPLStar.swift](/CPLStar.swift) CPL with minimum changes can be used even in Xcode 10.1, just remove all statements starting with `if #available(iOS 14.0, macOS 11.0, *)`.\n\n## Third-party software\n\n| Type   | Name                                                                                                                              | License                            |\n| ------ | --------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------- |\n| Style  | [SwiftLint](https://github.com/realm/SwiftLint) / [v0.57.0 for Monterey+](https://github.com/realm/SwiftLint/releases/tag/0.57.0) | MIT                                |\n| Script | [SwiftLint Shell Script](/SucceedsPostAction.sh) to run SwiftLint                                                                 | MIT                                |\n| Action | [mxcl/xcodebuild@v3](https://github.com/mxcl/xcodebuild)                                                                          | [Unlicense](https://unlicense.org) |\n| Action | [cirruslabs/swiftlint-action@v1](https://github.com/cirruslabs/swiftlint-action/)                                                 | MIT                                |\n\n# Installation\n\n\u003e Standalone: the single source code file [CPLStar.swift](/CPLStar.swift)\n\n\u003e Swift Package Manager: `https://github.com/perseusrealdeal/ConsolePerseusLogger`\n\n\u003e [!NOTE]\n\u003e If output is consoleapp and Environment Variable `OS_ACTIVITY_MODE` in `disable` log messaging will be restricted for Xcode console, but only.\n\n![Image](https://github.com/user-attachments/assets/fb64c5cf-70dc-489c-9850-976ea3d5800c)\n\n# Usage\n\n## Log to the console\n\n```swift\n\nimport ConsolePerseusLogger\n\nlog.message(\"[\\(type(of: self))].\\(#function)\")\n\n```\n\n![Image](https://github.com/user-attachments/assets/fde70234-5faa-4afe-ad1f-2bfc24ee8f7d)\n\n## Log to macOS Console.app\n\n```swift\n\nimport ConsolePerseusLogger\n\n// MARK: - Log to Console.app\n\n// log.logObject = (\"MyApp\", \"MyLover\") // Customs for Console.app Subsystem and Category.\n\nlog.output = .consoleapp\nlog.message(\"The app's start point...\", .info)\n\n```\n\n![Image](https://github.com/user-attachments/assets/04e2618f-7b83-401a-bc7b-87bdc91fb9e9)\n\n## Custom log\n\n```swift\n\nimport ConsolePerseusLogger\n\ntypealias Level = ConsolePerseusLogger.PerseusLogger.Level\n\nfunc customPrint(_ text: String, _ type: Level, _ localTime: LocalTime, _ owner: PIDandTID) {\n\n    let time = \"[\\(localTime.date)] [\\(localTime.time)]\"\n    let id = \"[\\(owner.pid):\\(owner.tid)]\"\n\n    print(\"[MYLOG] [\\(type)] \\(time) \\(id) \\(text)\")\n}\n\nlog.customActionOnMessage = customPrint(_:_:_:_:)\n\nlog.format = .textonly\nlog.output = .custom\n\nlog.message(\"The app's start point...\", .info)\n\n```\n\n![Image](https://github.com/user-attachments/assets/fe135516-7ab2-4747-8954-fd1ffe768483)\n\n## Debugging SwiftUI\n\n`Case 1:` as is\n\n```swift\n\nImage(systemName: \"globe\")\n    .onAppear {\n        log.message(\"This is the debug output.\")\n    }\n\n```\n\n`Case 2:` wrapper\n\n\u003e Add an extension on View that returns itself and calls the logger's message method:\n\n```swift\n\nextension View {\n    func message(_ text: @autoclosure () -\u003e String,\n                 _ type: PerseusLogger.Level = .debug,\n                 _ oput: PerseusLogger.Output = PerseusLogger.output,\n                 _ file: StaticString = #file,\n                 _ line: UInt = #line) -\u003e Self {\n\n        log.message(text(), type, oput, file, line)\n\n        return self\n    }\n}\n\n```\n\n\u003e Then use message as a view modifier to print debug information to the console when the view is built:\n\n```swift\n\nVStack {\n   ForEach(colors, id: \\.self) { color in\n      Circle()\n         .foregroundColor(color)\n         .message(\"\\(color)\")\n   }\n}\n\n```\n\n![Image](https://github.com/user-attachments/assets/bdc3e71f-123c-42b8-b3ae-d98a34f99520)\n\n## Log level and message types\n\n\u003e CPL applies the most common log types for indicating information category.\n\n| Level | Message Type | Description                           |\n| :---: | :----------- | :------------------------------------ |\n| 5     | DEBUG        | Debugging only                        |\n| 4     | INFO         | Helpful, but not essential            |\n| 3     | NOTICE       | Might result in a failure             |\n| 2     | ERROR        | Errors seen during the code execution |\n| 1     | FAULT        | Faults and bugs in the code           |\n\n\u003e Also, CPL considers Message Type to filter, look how it works:\n\n![Image](https://github.com/user-attachments/assets/23b72f6e-39b9-4d7d-be27-7374436deb42)\n\n## Setting the Logger Up\n\n\u003e Default values of CPL options depend on DEBUG/RELEASE.\n\n| Option      | Default in DEBUG     | Default in RELEASE   |\n| :---------- | :------------------- | :------------------- |\n| tuned       | .on                  | .off                 |\n| output      | .standard            | .consoleapp          |\n| level       | .debug               | .notice              |\n\n\u003e Other CPL options are the same for DEBUG/RELEASE by default. \n\n| Option      | Default in DEBUG     | Default in RELEASE   |\n| :---------- | :------------------- | :------------------- |\n| subsecond   | .nanosecond          | .nanosecond          |\n| tidnumber   | .hexadecimal         | .hexadecimal         |\n| format      | .short               | .short               |\n| marks       | true                 | true                 |\n| time        | false                | false                |\n| owner       | false                | false                |\n| directives  | false                | false                | \n| logObject   | (\"Perseus\", \"Lover\") | (\"Perseus\", \"Lover\") |\n\n\u003e Special option goes kinda lifehack. Matter only if Simulator. \n\n| Option      | Default in DEBUG     | Default in RELEASE   |\n| :---------- | :------------------- | :------------------- |\n| debugIsInfo | true                 | true                 |\n\n### Load (reset) CPL options with JSON config\n\n\u003e Each option can be reseted in run time with json config except option `turned`.\n\n`Case 1:` Using predefined json profile\n\n```swift\n\nimport ConsolePerseusLogger\n\nlet isReseted = log.loadConfig(.debugRoutine)\nlet result = isReseted ? \"CPL current options loaded.\" : \"Failed to load options!\"\n\nlog.message(result)\n\n```\n\n`Case 2:` Using custom profile (URL required)\n\n```swift\n\nimport ConsolePerseusLogger\n\nvar result = \"\"\n\nif let path = Bundle.main.url(forResource: \"CPLConfig\", withExtension: \"json\") {\n    let isLoaded = log.loadConfig(path)\n    result = isLoaded ? \"Options successfully loaded.\" : \"Failed to load options!\"\n} else {\n    result = \"Failed to create URL!\"\n}\n\nlog.message(result)\n\n```\n\n![Image](https://github.com/user-attachments/assets/32c6dcee-11ad-44d6-add0-ee8e6ae6c465)\n\n## CPL in SPM package\n\n\u003e In case if CPL in use as a standalone file in SPM package.\n\n```swift\n\n//\n//  main.swift\n//\n\nimport ConsolePerseusLogger\n\nimport class PackageA.PerseusLogger\nimport class PackageB.PerseusLogger\n\ntypealias logA = PackageA.PerseusLogger\ntypealias logB = PackageB.PerseusLogger\n\n// MARK: - Subloggers\n\nlogA.turned = .off\nlogB.turned = .off\n\n// MARK: - Logger\n\nlog.message(\"The app's start point...\", .info)\n\n```\n\n## Console.app and Simulator\n\n\u003e Just a matter of fact that Console.app doesn't show any DEBUG message from any app running on Simulator (even if \"Include Debug Messages\" tapped in Console.app).\u003cbr/\u003e\n\n\u003e Console Perseus Logger running on Simulator doesn't pass DEBUG message to Console.app, instead it passes INFO message with text of DEBUG message by default if Simulator runs, so, a passed message being INFO looks like a DEBUG and it works perfactly well.\u003cbr/\u003e\n\n\u003e If for some reasons CPL must pass DEBUG like a DEBUG message the option should take false `log.debugIsInfo = false`.\n\n```swift\n\n#if targetEnvironment(simulator)\n    log.debugIsInfo = false\n#endif\n\n```\n\n# Points taken into account\n\n- Preconfigured Swift Package manifest [Package.swift](/Package.swift)\n- Preconfigured SwiftLint config [.swiftlint.yml](/.swiftlint.yml)\n- Preconfigured SwiftLint CI [swiftlint.yml](/.github/workflows/swiftlint.yml)\n- Preconfigured GitHub config [.gitignore](/.gitignore)\n- Preconfigured GitHub CI [main.yml](/.github/workflows/main.yml)\n\n# License MIT\n\nCopyright © 7531 - 7533 Mikhail A. Zhigulin of Novosibirsk\u003cbr/\u003e\nCopyright © 7531 - 7533 PerseusRealDeal\n\n- The year starts from the creation of the world according to a Slavic calendar.\n- September, the 1st of Slavic year. It means that \"Sep 01, 2024\" is the beginning of 7533.\n\n## Other Required License Notices\n\n© 2025 The SwiftLint Contributors **for** SwiftLint\u003c/br\u003e\n© GitHub **for** GitHub Action cirruslabs/swiftlint-action@v1\u003c/br\u003e\n© 2021 Alexandre Colucci, geteimy.com **for** Shell Script SucceedsPostAction.sh\u003c/br\u003e\n\n[LICENSE](/LICENSE) for details.\n\n## Credits\n\n\u003ctable\u003e\n\u003ctr\u003e\n    \u003ctd\u003eBalance and Control\u003c/td\u003e\n    \u003ctd\u003ekept by\u003c/td\u003e\n    \u003ctd\u003eMikhail A. Zhigulin\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n    \u003ctd\u003eSource Code\u003c/td\u003e\n    \u003ctd\u003ewritten by\u003c/td\u003e\n    \u003ctd\u003eMikhail A. Zhigulin\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n    \u003ctd\u003eDocumentation\u003c/td\u003e\n    \u003ctd\u003eprepared by\u003c/td\u003e\n    \u003ctd\u003eMikhail A. Zhigulin\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n    \u003ctd\u003eProduct Approbation\u003c/td\u003e\n    \u003ctd\u003etested by\u003c/td\u003e\n    \u003ctd\u003eMikhail A. Zhigulin\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n- Language support: [Reverso](https://www.reverso.net/)\n- Git clients: [SmartGit](https://syntevo.com/) and [GitHub Desktop](https://github.com/apps/desktop)\n\n# Author\n\n\u003e © Mikhail A. Zhigulin of Novosibirsk.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fperseusrealdeal%2Fconsoleperseuslogger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fperseusrealdeal%2Fconsoleperseuslogger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fperseusrealdeal%2Fconsoleperseuslogger/lists"}