Logging

How to use Pulse logger

The recommended way to store messages is by using PersistentLogHandler, which is a logging backend for SwiftLog.

Bootstrapping #

First, you need to intruct SwiftLog to use Pulse logging backend.

import Pulse
import Logging

LoggingSystem.bootstrap(PersistentLogHandler.init)

Pulse.PersistentLogHandler is a wrapper for PulseCore.LoggerStore. If you are not using SwiftLog in your project, you can use PulseCore.LoggerStore directly. Unlike Pulse framework, PulseCore has no dependency to SwiftLog.

Pulse hasn’t reached 1.0 state yet, cosinder disabling it in production.

Logging #

Use SwiftLog as usual to start logging messages.

let logger = Logger(label: "com.yourcompany.yourapp")

/// ...

logger.info("This message will be stored persistently")

Remote Logging #

If you are a Pulse Pro user, you’ll also need to add the following to your app’s plist file:

<key>NSLocalNetworkUsageDescription</key>
<string>Network usage required for debugging purposes </string>
<key>NSBonjourServices</key>
<array>
  <string>_pulse._tcp</string>
</array>

Pulse won’t show any permission dialogs unless you enable remote logging from the settings.

Logging Network Request #

Pulse supports logging URLSession tasks and offers a simple Alamofire integration. For more information, please follow the next guide.