Skip to content

e-sites/swift-log-papertrail

Repository files navigation

swift-log-papertrail

Swift

This package implements a handler for swift-log which will send log messages to the Papertrail's Log Management service.

Usage

Add Package

Integrate the PapertrailLogHandler package as a dependency with Swift Package Manager. Add the following to Package.swift:

.package(url: "https://github.com/e-sites/swift-log-papertrail.git", from: "1.0.0")

Add PapertrailLogHandler to your target dependencies:

.product(name: "PapertrailLogHandler", package: "swift-log-papertrail")

Configure

Configure the logger by bootstrapping a PapertrailLogHandler instance.

import PapertrailLogHandler
import Logging

LoggingSystem.bootstrap { label in
	return PapertrailLogHandler(label: label,
	                            host: "logs9.papertrailapp.com",
	                            port: 1234,
	                            programName: UUID().uuidString)
	                            
	// Or use `MultiplexLogHandler` to use multiple LogHandlers
}

Logging

To send logs to Papertrail, initialize a Logger instance and send a message with optional additional metadata:

import Loggingx

let logger = Logger(label: "com.swift-log.awesome-app")
logger.error("unfortunate error", metadata: ["request-id": "abc-123"])

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published