Swiftpack.co - NSHipster/swift-log-github-actions as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
GitHub Actions workflow logging for Swift
.package(url: "https://github.com/NSHipster/swift-log-github-actions.git", from: "1.0.0")


A logging backend for SwiftLog that translates logging messages into workflow commands for GitHub Actions.


  • Swift 5.1+


Conditionally Bootstrapping GitHubActionsLogHandler

import Logging
import LoggingGitHubActions
import struct Foundation.ProcessInfo

LoggingSystem.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.

import Logging

let logger = Logger(label: "com.example.MyApp")
logger.error("Something went wrong")
// Prints "::error file=Sources/main.swift,line=5::Something went wrong
GitHub Actions UI


Swift Package Manager

Add swift-log-github-actions as a dependency to your Package.swift file.

.package(url: "https://github.com/NSHipster/swift-log-github-actions.git", from: "1.0.0")

Add "LoggingGitHubActions to your target's dependencies.

.target(name: "Example",
        dependencies: ["LoggingGitHubActions"])




Mattt (@mattt)


Stars: 70
Last commit: 16 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Submit a free job ad (while I'm testing this). The analytics numbers for this website are here.


Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics