ShipBook gives you the power to remotely gather, search and analyze your user logs and exceptions in the cloud, on a per-user & session basis.
SwiftLog is a lightweight logging API for Swift that was created by the Swift Server Working Group. It is under apple's umbrella and is a part of the swift server ecosystem, and works on all platforms that Swift supports. It is slowly becoming the standard for logging in Swift.
To integrate Shipbook with SwiftLog, you need to add the LoggingShipbook package to your project. There are two ways to do this:
Add the LoggingShipbook package as a dependency to your Package.swift
file.
dependencies: [
package(url: "https://github.com/ShipBook/swift-log-shipbook.git", from: "1.0.0")
]
Or under Xcode, go to File
-> Swift Packages
-> Add Package Dependency
and enter the URL for the LoggingShipbook package https://github.com/ShipBook/swift-log-shipbook.git.
Then, you can use the LoggingShipbook
package to send logs to Shipbook.
import Logging
import LoggingShipbook
let logger = Logger(label: "com.example.MyApp")
ShipBook.start(appId:"YOUR_APP_ID", appKey:"YOUR_APP_KEY")
LoggingSystem.bootstrap(ShipbookLogHandler.init)
Now you can use SwiftLog as you normally would and all logs will be sent to Shipbook.
logger.info("Hello, world!")
The log levels in SwiftLog are different from those in Shipbook. To map the log levels, you can use the following mapping table:
SwiftLog Level | Shipbook Level |
---|---|
trace | verbose |
debug | debug |
info | info |
notice | warning |
warning | warning |
error | error |
critical | error |
For more information about the usage of shipbook and its features, please visit Shipbook iOS Log integration.