logger
To gather useful information from the SDK, you can either use default SDK Logger or implement and assign your own logger that the SDK will use to send log messages.
Log messages are assigned one of these levels: debug
, info
, warning
, error
, and none
.
The default logger has a log level of .none
.
This allows simple and powerful filtering of log messages so that you can, for example, print debug messages to the local console and send error messages to an external aggregator.
The default behaviour of the logger is not to send any logs at all unless the
DEBUG
compilation symbol is present - this avoids any PCI or PII being
logged in production reporting tools.
Implementing your own custom logger
To implement a logger, create a class or struct that implements PrimerLogger
, like so:
Then assign an instance to the logger
property:
If you want to change the logs that you receive based on log level, set the logLevel
property like so:
If you don’t want to receive any logs, set the log level to .none
.
Default SDK logger
The SDK provides a default logger that will print to the Xcode and/or macOS console using
either OSLogger
(if available) or print
.
Note that the default logger has a log level of none
, so it won’t send any logs at all
unless you assign a different level.
You can easily assign .debug
or any other log level to the default logger by simply calling: