Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/NSHipster/swift-log-github-actions
GitHub Actions workflow logging for Swift
https://github.com/NSHipster/swift-log-github-actions
github-actions swift swift-log
Last synced: 3 months ago
JSON representation
GitHub Actions workflow logging for Swift
- Host: GitHub
- URL: https://github.com/NSHipster/swift-log-github-actions
- Owner: NSHipster
- License: mit
- Archived: true
- Created: 2020-03-25T20:01:33.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2021-06-01T11:57:09.000Z (over 3 years ago)
- Last Synced: 2024-11-14T14:49:06.712Z (3 months ago)
- Topics: github-actions, swift, swift-log
- Language: Swift
- Homepage: https://nshipster.com/swift-log/
- Size: 19.5 KB
- Stars: 72
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# LoggingGitHubActions
A logging backend for [SwiftLog](https://github.com/apple/swift-log)
that translates logging messages into
[workflow commands for GitHub Actions](https://help.github.com/en/actions/reference/workflow-commands-for-github-actions).## Requirements
- Swift 5.1+
## Usage
### Conditionally Bootstrapping GitHubActionsLogHandler
```swift
import Logging
import LoggingGitHubActions
import struct Foundation.ProcessInfoLoggingSystem.bootstrap { label in
if ProcessInfo.processInfo.environment["GITHUB_ACTIONS"] == "true" {
return GitHubActionsLogHandler.standardOutput(label: label)
} else {
return StreamLogHandler.standardOutput(label: label)
}
}
```## Using a Logger
Create an instance of `Logger` and log messages accordingly.
When your program is run as a step in a GitHub Actions workflow,
warning and error messages will be formatted in such a way that
it'll be surfaced in the GitHub Actions UI.```swift
import Logginglet logger = Logger(label: "com.example.MyApp")
logger.error("Something went wrong")
// Prints "::error file=Sources/main.swift,line=5::Something went wrong
```
## Installation
### Swift Package Manager
Add `swift-log-github-actions` as a dependency to your `Package.swift` file.
```swift
.package(url: "https://github.com/NSHipster/swift-log-github-actions.git", from: "1.0.0")
```Add `"LoggingGitHubActions` to your target's dependencies.
```swift
.target(name: "Example",
dependencies: ["LoggingGitHubActions"])
```## License
MIT
## Contact
Mattt ([@mattt](https://twitter.com/mattt))