Appearance
Logs
The SDK includes an optional logging feature that lets apps save encrypted, lightweight log files locally. These logs can assist in diagnosing unexpected behavior or other issues during SDK usage.
Through a configurable API, applications can:
- Specify which types of logs to collect.
- Choose whether logs are saved to a publicly accessible folder.
- Receive a notification when the logs are ready after a session completes.
To enable logging, use the withLogs(configuration:listener:) method available on both FaceSessionBuilder and PPGDeviceSessionBuilder.
Creating a Session with Logs
Create a LogsConfiguration object and pass it to withLogs(configuration:listener:). Optionally, provide a LogsListener to receive a callback when the logs are saved.
Swift
do {
let licenseDetails = LicenseDetails(licenseKey: "<ENTER_YOUR_LICENSE_KEY>")
let logsConfiguration = LogsConfiguration(
level: .default,
saveToPublicFolder: true
)
let session = try FaceSessionBuilder()
.withImageListener(self)
.withVitalSignsListener(self)
.withSessionInfoListener(self)
.withLogs(configuration: logsConfiguration, listener: self)
.build(licenseDetails: licenseDetails)
}
catch {
let e = error as NSError
print("Received Error. Domain: \(e.domain) Code: \(e.code)")
}Objective-c
BIOLicenseDetails *licenseDetails = [[BIOLicenseDetails alloc] initWithLicenseKey:@"<ENTER_YOUR_LICENSE_KEY>"];
BIOLogsConfiguration *logsConfiguration = [[BIOLogsConfiguration alloc] initWithLevel:[BIOLogsLevel default]
saveToPublicFolder:true];
BIOFaceSessionBuilder *sessionBuilder = [[[[[[BIOFaceSessionBuilder alloc] init]
withLogsConfiguration:logsConfiguration listener:self]
withImageListener:self]
withVitalSignsListener:self]
withSessionInfoListener:self];
NSError *error = nil;
id<BIOSession> _Nullable session = [sessionBuilder buildWithLicenseDetails:licenseDetails
error:&error];
if (error != nil) {
NSLog(@"Received Error. Domain: %@ Code: %ld", error.domain, (long)error.code);
}Logs Configuration
Use LogsConfiguration to control logging behavior.
Swift
public class LogsConfiguration: NSObject {
public let level: LogsLevel
public let saveToPublicFolder: Bool
public init(
level: LogsLevel,
saveToPublicFolder: Bool
)
}Objective-c
@interface BIOLogsConfiguration : NSObject
@property (nonatomic, readonly, strong) BIOLogsLevel * _Nonnull level;
@property (nonatomic, readonly) BOOL saveToPublicFolder;
- (nonnull instancetype)initWithLevel:(BIOLogsLevel * _Nonnull)level
saveToPublicFolder:(BOOL)saveToPublicFolder;
- (nonnull instancetype)init NS_UNAVAILABLE;
+ (nonnull instancetype)new NS_UNAVAILABLE;
@endlevel: The desired logging level (see Logs Level).saveToPublicFolder: Iftrue, logs are saved to a publicly accessible folder (for easy access or sharing).
Logs Level
Defines the verbosity and types of logs to collect. Currently, only the default level is available.
Swift
public class LogsLevel: NSObject {
public let rawValue: Int
public let name: String
public static let `default`: LogsLevel
}Objective-c
@interface BIOLogsLevel : NSObject
@property (nonatomic, readonly) NSInteger rawValue;
@property (nonatomic, readonly, copy) NSString * _Nonnull name;
+ (BIOLogsLevel * _Nonnull)default;
- (nonnull instancetype)init NS_UNAVAILABLE;
+ (nonnull instancetype)new NS_UNAVAILABLE;
@endrawValue: A numeric identifier for the log level. For the default level, the value is0.name: A human-readable name for the log level. For the default level, the value is"Default".
Logs Listener
Implement the LogsListener protocol to receive log information when the session ends.
Swift
public protocol LogsListener {
func onLogsReady(logsInfo: LogsInfo)
}Objective-c
@protocol BIOLogsListener
- (void)onLogsReadyWithLogsInfo:(BIOLogsInfo * _Nonnull)logsInfo;
@endThe SDK invokes this method after the logs are successfully saved.
Logs Info
The LogsInfo object provides details about the saved logs.
Swift
public class LogsInfo: NSObject {
public let logsPath: String
public let measurementDuration: Int
}Objective-c
@interface BIOLogsInfo : NSObject
@property (nonatomic, readonly, copy) NSString * _Nonnull logsPath;
@property (nonatomic, readonly) NSInteger measurementDuration;
- (nonnull instancetype)init NS_UNAVAILABLE;
+ (nonnull instancetype)new NS_UNAVAILABLE;
@endlogsPath: Full path to the saved log files.measurementDuration: Duration of the measurement in seconds.
Permissions
When saveToPublicFolder is set to true in LogsConfiguration, logs will be saved to the app’s Documents folder, making them accessible to users through the Files app under the “On My iPhone” section. To make the app visible in the Files app, include the following section in the app's Info.plist:
xml
<key>UIFileSharingEnabled</key>
<true/>
<key>LSSupportsOpeningDocumentsInPlace</key>
<true/>