Swiftpack.co -  wlisac/swift-log-slack as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
A logging backend for SwiftLog that sends log messages to Slack.
.package(url: "https://github.com/wlisac/swift-log-slack.git", from: "0.1.0")


swift platforms version twitter
build jazzy codecov

Welcome to LoggingSlack – a logging backend for SwiftLog that sends critical log messages to Slack.


Setup Incoming Webhooks

LoggingSlack uses Incoming Webhooks to send log messages to a Slack channel.

Once you've setup Incoming Webhooks, you should have a webhook URL that you can use to configure LoggingSlack.

Bootstrap SwiftLog

LoggingSlack is intended to be used as a secondary logging backend to send critical log messages directly to Slack.

You can use SwiftLog's MultiplexLogHandler to setup LoggingSlack with another logging backend.

import Logging
import LoggingSlack

let webhookURL = URL(string: "https://hooks.slack.com/services/T1MGQL1L8/RM2LE5QLF/YH036NhldqitdR1lVd5NLS6z")!

LoggingSystem.bootstrap { label in
        // Setup SlackLogHandler with a webhook URL 
        SlackLogHandler(label: label, webhookURL: webhookURL),
        // Setup the standard logging backend to enable console logging
        StreamLogHandler.standardOutput(label: label)

Using a Logger

You can now use SwiftLog as usual and critical log messages are sent directly to Slack.

import Logging

let logger = Logger(label: "com.example.ExampleApp.main")

logger.critical("Something went wrong!")

Logger Output

The logger will output a Slack message and a console message since both logging backends were setup.

2020-02-15T19:30:00-0800 critical: Something went wrong!

Log Level Threshold

Only critical log level messages are sent to Slack by default.

You can adjust the log level threshold by changing the globalLogLevelThreshold static property on SlackLogHandler.

For example, this will configure LoggingSlack to send all error log level and above messages to Slack.

SlackLogHandler.globalLogLevelThreshold = .error

API Documentation

Visit the online API reference for full documentation of the public API.


LoggingSlack requires Xcode 11 or a Swift 5.1 toolchain with the Swift Package Manager.

Swift Package Manager

Add the LoggingSlack package as a dependency to your Package.swift file.

.package(url: "https://github.com/wlisac/swift-log-slack.git", from: "0.1.0")

Add LoggingSlack to your target's dependencies.

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


Stars: 63
Last commit: 34 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.


Release Notes

1 year ago

Initial release 🎉

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