Skip to content

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 PolarSessionBuilder.

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.

dart
try {
  final licenseDetails = LicenseDetails(licenseKey: "<ENTER_YOUR_LICENSE_KEY>");
  
  final logsConfiguration = LogsConfiguration( 
    logsLevel: LogsLevel.defaultLogs,
    saveLogsToPublicFolder: true
  ); 
  
  final session = await FaceSessionBuilder() 
      .withImageListener(this)
      .withVitalSignsListener(this)
      .withSessionInfoListener(this)
      .withLogs(logsConfiguration, this) 
      .build(licenseDetails);
} catch (e) {
  print('Error creating session: $e');
}

Logs Configuration

Use LogsConfiguration to control logging behavior.

dart
class LogsConfiguration {
  final LogsLevel logsLevel;
  final bool saveLogsToPublicFolder;
}
  • logsLevel: The desired logging level (see Logs Level).
  • saveLogsToPublicFolder: If true, 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.

dart
enum LogsLevel {
  defaultLogs
}

Logs Listener

Implement the LogsListener abstract class to receive log information when the session ends.

dart
abstract class LogsListener {
  void onLogsReady(LogsInfo logsInfo);
}

The SDK invokes this method after the logs are successfully saved.

Logs Info

The LogsInfo object provides details about the saved logs.

dart
class LogsInfo {
  final int measurementDuration;
  final String logsPath;
}
  • measurementDuration: Duration of the measurement in seconds.
  • logsPath: Full path to the saved log files.

Permissions required for iOS

When saveLogsToPublicFolder 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/>