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, pass logging options directly to the SessionBuilder.faceSession() and SessionBuilder.polarSession() methods.
Creating a Session with Logs
Pass the logging configuration options as the second parameter to SessionBuilder.faceSession() and SessionBuilder.polarSession() method. Use the useLogsInfo hook to receive logs information when the session completes.
TypeScript
import {
SessionBuilder,
LogsLevel,
} from 'biosensesignal-react-native-sdk';
try {
const session = await SessionBuilder.faceSession(
{
licenseKey: "<ENTER_YOUR_LICENSE_KEY>"
},
{
logsLevel: LogsLevel.DEFAULT,
saveLogsToPublicFolder: true
}
);
} catch (e) {
const exception = (e as HealthMonitorException)
console.log(`Error: ${exception?.code}`);
}Logs Configuration
Configure logging behavior by passing options to SessionBuilder.faceSession():
logsLevel: The desired logging level (see Logs Level).saveLogsToPublicFolder: 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 - LogsLevel.DEFAULT.
TypeScript
export enum LogsLevel {
DEFAULT
}useLogsInfo hook
Use the useLogsInfo hook to receive log information when the session ends.
TypeScript
import {
useLogsInfo
} from 'biosensesignal-react-native-sdk';
const logsInfo = useLogsInfo();
React.useEffect(() => {
if (logsInfo) {
console.log("logsInfo", logsInfo);
}
}, [logsInfo]);The hook returns logs information after the logs are successfully saved.
Logs Info
The LogsInfo object provides details about the saved logs.
TypeScript
class LogsInfo {
readonly measurementDuration: number,
readonly logsPath: string
}logsPath: Full path to the saved log files.measurementDuration: Duration of the measurement in seconds.
Permissions required for iOS
When saveLogsToPublicFolder is set to true, 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/>