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.

If you are using PulseCore.LoggerStore directly, make sure to disable logging for your production builds.

Logging #

Use SwiftLog as usual to start logging messages.

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

/// ...

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

Logging Network Request #

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