{"id":19809496,"url":"https://github.com/space-code/log","last_synced_at":"2025-02-28T12:45:05.276Z","repository":{"id":201010938,"uuid":"706007769","full_name":"space-code/log","owner":"space-code","description":"Log is a lightweight logging framework written in Swift.","archived":false,"fork":false,"pushed_at":"2024-12-25T15:12:22.000Z","size":338,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"dev","last_synced_at":"2025-02-11T07:35:51.795Z","etag":null,"topics":["logger","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/space-code.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-17T06:06:41.000Z","updated_at":"2024-12-25T14:29:41.000Z","dependencies_parsed_at":null,"dependency_job_id":"f8c7c4fd-49d9-4870-9734-f79ef6f615da","html_url":"https://github.com/space-code/log","commit_stats":null,"previous_names":["space-code/log"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/space-code%2Flog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/space-code%2Flog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/space-code%2Flog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/space-code%2Flog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/space-code","download_url":"https://codeload.github.com/space-code/log/tar.gz/refs/heads/dev","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241152746,"owners_count":19918674,"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":["logger","logging","swift"],"created_at":"2024-11-12T09:17:11.974Z","updated_at":"2025-02-28T12:45:05.255Z","avatar_url":"https://github.com/space-code.png","language":"Swift","readme":"![Log: A lightweight logging framework written in Swift](https://raw.githubusercontent.com/space-code/log/dev/Resources/log.png)\n\n\u003ch1 align=\"center\" style=\"margin-top: 0px;\"\u003elog\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://github.com/space-code/log/blob/main/LICENSE\"\u003e\u003cimg alt=\"License\" src=\"https://img.shields.io/github/license/space-code/log?style=flat\"\u003e\u003c/a\u003e\n\u003ca href=\"https://swiftpackageindex.com/space-code/log\"\u003e\u003cimg alt=\"Swift Compatibility\" src=\"https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fspace-code%2Flog%2Fbadge%3Ftype%3Dswift-versions\"/\u003e\u003c/a\u003e \n\u003ca href=\"https://swiftpackageindex.com/space-code/log\"\u003e\u003cimg alt=\"Platform Compatibility\" src=\"https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fspace-code%2Flog%2Fbadge%3Ftype%3Dplatforms\"/\u003e\u003c/a\u003e \n\u003ca href=\"https://github.com/space-code/log\"\u003e\u003cimg alt=\"CI\" src=\"https://github.com/space-code/Log/actions/workflows/ci.yml/badge.svg?branch=main\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/apple/swift-package-manager\" alt=\"log on Swift Package Manager\" title=\"log on Swift Package Manager\"\u003e\u003cimg src=\"https://img.shields.io/badge/Swift%20Package%20Manager-compatible-brightgreen.svg\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://codecov.io/gh/space-code/log\"\u003e\u003cimg alt=\"CodeCov\" src=\"https://codecov.io/gh/space-code/log/graph/badge.svg?token=h5C53DgBKN\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/space-code/log\"\u003e\u003cimg alt=\"GitHub release; latest by date\" src=\"https://img.shields.io/github/v/release/space-code/log\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/space-code/log\"\u003e\u003cimg alt=\"GitHub commit activity\" src=\"https://img.shields.io/github/commit-activity/m/space-code/log\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## Description\n`Log` is a lightweight logging framework written in Swift.\n\n- [Usage](#usage)\n- [Requirements](#requirements)\n- [Installation](#installation)\n- [Communication](#communication)\n- [Contributing](#contributing)\n- [Author](#author)\n- [License](#license)\n\n## Usage\n\n### Create a logger instance\n\nFirst, you need to create an instance of `IPrinter` that prints messages to a specific output, such as XCode's console or the `Console` app.\nThe `log` package provides predefined printers for printing messages in the XCode console (`ConsolePrinter`) and the system console (`OSPrinter`). You can also create your own printer. To do this, your object must conform to `IPrinterStrategy` and implement the necessary methods.\n\n```swift\nimport Log\n\nlet osPrinter = OSPrinter()\nlet consolePrinter = ConsolePrinter()\n```\n\nSecond, create a `Logger` instance and pass these printers as initialization parameters while defining a log level. The log level determines the level of log messages to print. If the log level is set to a specific level, all messages with different log levels will be ignored. To print all messages, use `.all`.\n\n```swift\nlet log = Logger(\n    printers: [osPrinter, consolePrinter],\n    logLevel: .all\n)\nlog.error(message: \"test message\")\n```\n\n### Formatting a message\n\nEach instance of `IPrinter` has an array of formatters that are responsible for formatting input messages. The `log` package provides predefined prefix and timestamp formatters. To use these, you need to pass them to an initializer of a printer.\n\n```swift\nlet osPrinter = OSPrinter(formatters: [PrefixFormatter(name: \"your prefix here\")])\n...\nlog.fault(message: \"message\") // \"🚨🚨🚨 [your prefix here] =\u003e message\"\n```\n\nHere is a list of predefined formatters:\n\n| **Formatters**             | **Description**                                                                     |\n|----------------------------|-------------------------------------------------------------------------------------|\n| **PrefixLogFormatter**     | Add a specified prefix to a printed message                                         |\n| **TimestampLogFormatter**  | Add a timestamp before a printed message based on a date format                     |\n\n### Custom formatters\n\nIf you want to create a custom message formatter, your object must conform to the `ILogFormatter` protocol and implement the necessary methods.\n\n```swift\nstruct MyCustomMessageFormatter: ILogFormatter {\n    func format(message: String, with logLevel: LogLevel) -\u003e String {\n        // your implementation here\n    }\n}\n```\n\n## Requirements\n- iOS 13.0+ / macOS 10.15+ / tvOS 13.0+ / watchOS 7.0+ / visionOS 1.0+\n- Xcode 14.0\n- Swift 5.7\n\n## Installation\n### Swift Package Manager\n\nThe [Swift Package Manager](https://swift.org/package-manager/) is a tool for automating the distribution of Swift code and is integrated into the `swift` compiler. It is in early development, but `log` does support its use on supported platforms.\n\nOnce you have your Swift package set up, adding `log` as a dependency is as easy as adding it to the `dependencies` value of your `Package.swift`.\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/space-code/log.git\", .upToNextMajor(from: \"1.2.0\"))\n]\n```\n\n## Communication\n- If you **found a bug**, open an issue.\n- If you **have a feature request**, open an issue.\n- If you **want to contribute**, submit a pull request.\n\n## Contributing\nBootstrapping development environment\n\n```\nmake bootstrap\n```\n\nPlease feel free to help out with this project! If you see something that could be made better or want a new feature, open up an issue or send a Pull Request!\n\n## Author\nNikita Vasilev, nv3212@gmail.com\n\n## License\nlog is available under the MIT license. See the LICENSE file for more info.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspace-code%2Flog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspace-code%2Flog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspace-code%2Flog/lists"}