{"id":32151573,"url":"https://github.com/l1men9yu/senna","last_synced_at":"2026-02-18T21:01:25.922Z","repository":{"id":45783601,"uuid":"211647198","full_name":"L1MeN9Yu/Senna","owner":"L1MeN9Yu","description":"a logging engine backend of Apple's swift-log","archived":false,"fork":false,"pushed_at":"2023-10-13T08:27:04.000Z","size":1179,"stargazers_count":11,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-28T19:27:59.355Z","etag":null,"topics":["logger","logging","logging-library","swift","swift-log"],"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/L1MeN9Yu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null},"funding":{"github":["L1MeN9Yu"]}},"created_at":"2019-09-29T10:41:12.000Z","updated_at":"2025-11-29T21:08:38.000Z","dependencies_parsed_at":"2022-07-17T00:00:46.186Z","dependency_job_id":"2f6292ab-bd42-4ade-89ab-1d6e76cdabe5","html_url":"https://github.com/L1MeN9Yu/Senna","commit_stats":{"total_commits":155,"total_committers":1,"mean_commits":155.0,"dds":0.0,"last_synced_commit":"e94c6d33d2abfc60be6f876b74702278e4471cc1"},"previous_names":[],"tags_count":41,"template":false,"template_full_name":null,"purl":"pkg:github/L1MeN9Yu/Senna","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/L1MeN9Yu%2FSenna","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/L1MeN9Yu%2FSenna/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/L1MeN9Yu%2FSenna/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/L1MeN9Yu%2FSenna/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/L1MeN9Yu","download_url":"https://codeload.github.com/L1MeN9Yu/Senna/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/L1MeN9Yu%2FSenna/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29596104,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-18T20:59:56.587Z","status":"ssl_error","status_checked_at":"2026-02-18T20:58:41.434Z","response_time":162,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["logger","logging","logging-library","swift","swift-log"],"created_at":"2025-10-21T10:47:43.163Z","updated_at":"2026-02-18T21:01:25.917Z","avatar_url":"https://github.com/L1MeN9Yu.png","language":"Swift","funding_links":["https://github.com/sponsors/L1MeN9Yu"],"categories":[],"sub_categories":[],"readme":"# Senna\n\n**a logging engine backend of Apple's** [swift-log](https://github.com/apple/swift-log)\n\n## Status\n\n![Swift5.0+](https://img.shields.io/badge/Swift-5.0%2B-orange.svg?style=flat)\n[![release](https://img.shields.io/github/v/release/L1MeN9Yu/Senna.svg?color=blue)](https://github.com/L1MeN9Yu/Senna/releases)\n[![Build](https://github.com/L1MeN9Yu/Senna/actions/workflows/Build.yml/badge.svg)](https://github.com/L1MeN9Yu/Senna/actions/workflows/Build.yml)\n[![codecov](https://codecov.io/gh/L1MeN9Yu/Senna/branch/main/graph/badge.svg?token=0ZQSVH4ERX)](https://codecov.io/gh/L1MeN9Yu/Senna)\n[![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/L1MeN9Yu/Senna/blob/main/LICENSE)\n\n[![platforms](https://img.shields.io/badge/Platforms-macOS%20%7C%20iOS%20%7C%20tvOS%20%7C%20watchOS%20%7C%20Linux-orange.svg?style=flat)](https://github.com/L1MeN9Yu/Senna/blob/main/Package.swift)\n\n## Features\n\n* Pure Swift\n* Backend of `apple/swift-log`\n* Both Darwin(iOS macOS watchOS tvOS) and Linux compatibility\n* Builtin output target : `[stdout/stderr,file,oslog,syslog]`\n* ANSI escape code\n* Complete customizable for text out\n* Support string interpolation the same as [Apple's Unified Logging System](https://developer.apple.com/documentation/os/logging/generating_log_messages_from_your_code)\n* 100% Code Coverage\n\n## Examples\n\n### Use Builtin Sinks\n\n#### Simple stdout\n\n```swift\n//create sink\nlet sink = StandardSink.out()\n//create formation\nlet formation = Formation.standard\n//create log\nvar logger = Logger(label: \"LogName\") {\n    Handler(name: $0, sink: sink, formation: formation, logLevel: .trace)\n}\n// do some logs\nlogger.trace(\"This is a trace message\")\nlogger.debug(\"This is a debug message\")\nlogger.info(\"This is a info message\")\nlogger.notice(\"This is a notice message\")\nlogger.warning(\"This is a warning message\")\nlogger.error(\"This is a error message\")\nlogger.critical(\"This is a critical message\")\n ```\n\nTerminal out :\n\n![](Documentations/README/Resources/stdout.png)\n\n#### Change LogLevel\n\n```swift\nlogger.logLevel = .info\nlogger.debug(\"will not log\")\nlogger.info(\"will log\")\n```\n\n#### Add MetaData\n\n```swift\nlogger[metadataKey: \"UserID\"] = .stringConvertible(9527)\nlogger.info(\"message with logger meta data\")\nlogger.info(\"message with both logger and message meta data\", metadata: [\"UserName\": .string(\"L1MeN9Yu\")])\n```\n\nTerminal out :\n\n![](Documentations/README/Resources/stdout_message_with_metadata.png)\n\n### Builtin Sinks\n\n#### FileSink\n\n```swift\nlet fileSink = FileSink(\"path/of/log\")\n```\n\nLog message will write to file.\n\nSee [Tests](Tests/FileSinkTests.swift) for more.\n\n#### OSLogSink (Apple platform only)\n\n```swift\nlet osLogSink = OSLogSink(subsystem: \"subsystem\", category: \"category\")\n```\n\nLog message will write to OS log (Apple's syslog). Use `Connsole.app` in your macOS to watch oslog messages.\n\nSee [Tests](Tests/OSLogSinkTests.swift) for more.\n\n#### SystemLogSink (Linux)\n\n```swift\nlet systemLogSink = SystemLogSink()\n```\n\nLog message will write to syslog.\n\nSee [Tests](Tests/SystemLogSinkTests.swift) for more.\n\n### Formation\n\n`Formation` generate the log message.\n\nThere are some builtin `Formation`:\n\n1. `Formation.standard`. This is default for `stdout/stderr`.\n2. `Formation.standardXcode`. This is default for `stdout/stderr` display in Xcode due Xcode's console is not support ANSI escape code.\n![](Documentations/README/Resources/stdout_xcode.png)\n3. `Formation.file`. This is default for `File`.\n4. `Formation.os`. This is default for `OSLog`.\n5. `Formation.system`. This is default for `syslog`.\n\n### Advanced Customize Formation\n\nCreate `Formation` is simple : `Formation(components: \u003c#T##[Component]##[Senna.Component]#\u003e, printer: \u003c#T##Printable?##Senna.Printable?#\u003e, separator: \u003c#T##String?##Swift.String?#\u003e)`\n\nThe Formation contains `components: [Component]`, `printer: Printable?` and `separator: String?`.\n\n#### Component\n\nComponent is your log message's element. See [Component](Sources/Types/Component.swift) file.\n\n#### Printable\n\nThe `Printable` enhanced your log messages, It can add color or style to the component.\n\nThe builtin `Printer` has two default instance.\n`Printer.standard` for `stdout/stderr`.\n`Printer.xcode` for `stdout/stderr` in Xcode.\n\nYou can create new `Printer` instance or Use `YourPrinter` which implements `Printable` protocol.\n\nSee [Printer](Sources/Implements/Printer.swift) and [Printable](Sources/Protocols/Printable.swift) for more.\n\n#### Separator\n\nThe `Separator` string is used for split log message's component.\nThe `Formation.standard`'s separator is `\" ▶ \"`.\n\n### Apple's Unified Logging System\n\nSenna reimplement the string interpolation behavior of [Apple's Unified Logging System](https://developer.apple.com/documentation/os/logging/generating_log_messages_from_your_code)\n\n```swift\nlet sink = StandardSink.out()\nlet formation = Formation.standard\nvar logger = Logger(label: \"LogName\") {\n    Handler(name: $0, sink: sink, formation: formation, logLevel: .trace)\n}\nlogger[metadataKey: \"UserID\"] = .stringConvertible(9527)\n#if DEBUG\nlet privacy = Privacy.public\n#else\nlet privacy = Privacy.private\n#endif\n// default is private\nlogger.senna.notice(\"the user name is \\(\"L1MeN9Yu\")\")\nlogger.senna.notice(\"the user name is \\(\"L1MeN9Yu\", privacy: privacy)\")\n```\n\nTerminal out :\n\n![](Documentations/README/Resources/stdout.string.interpolation.png)\n\nsee [LoggerSennaTests.swift](Tests/LoggerSennaTests.swift) for more usages.\n\n## Installation\n\n### Swift Package Manager\n\nAdd the following to your `Package.swift` file:\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/L1MeN9Yu/Senna.git\", from: \"3.0.0\")\n]\n```\n\n## Credit\n\n* [swift-log](https://github.com/apple/swift-log)\n* [swift-log-format-and-pipe](https://github.com/Adorkable/swift-log-format-and-pipe)\n* [spdlog](https://github.com/gabime/spdlog)\n* [Rainbow](https://github.com/onevcat/Rainbow)\n* [Logging](https://github.com/shaps80/Logging)\n\n## License\n\nSenna is available under the [MIT license](http://www.opensource.org/licenses/mit-license). See the LICENSE file for details.\n\n## Thanks | 鸣谢\n\nThanks to [JetBrains][JetBrains] for \"Licenses for Open Source Development\". [JetBrains][JetBrains] supports non-commercial open source projects by providing core project contributors with a set of best-in-class\ndeveloper tools free of charge.\n\n感谢 [JetBrains][JetBrains] 提供的开源开发许可证。[JetBrains][JetBrains] 通过为项目核心开发者免费提供开发工具来支持非商业开源项目。\n\n[JetBrains]: https://www.jetbrains.com/?from=Senna\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fl1men9yu%2Fsenna","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fl1men9yu%2Fsenna","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fl1men9yu%2Fsenna/lists"}