Logging & Monitoring
The library includes a comprehensive centralized logging system for debugging and monitoring biometric operations.
The library only logs in development builds (when __DEV__ is true). Release builds compile its logging out, so in production these functions don't produce any entries from library calls. See Development and Release Builds.
enableLogging()
Enables or disables the centralized logging system.
const enableLogging = (enabled: boolean): void => {
};
setLogLevel()
Sets the minimum log level for output.
enum LogLevel {
DEBUG = 0,
INFO = 1,
WARN = 2,
ERROR = 3
}
const setLogLevel = (level: LogLevel): void => {
};
configureLogger()
Configures the logger with advanced options.
type LoggerConfig = {
enabled: boolean;
level: LogLevel;
useColors: boolean;
prefix: string;
includeTimestamp: boolean;
includeContext: boolean;
maxStoredLogs: number;
};
const configureLogger = (config: Partial<LoggerConfig>): void => {
};
getLogs()
Retrieves stored log entries for analysis.
type LogEntry = {
timestamp: string;
level: LogLevel;
message: string;
context?: string;
data?: any;
error?: Error;
};
const getLogs = (): LogEntry[] => {
};
clearLogs()
Clears all stored log entries.
const clearLogs = (): void => {
};
Example Usage
import {
enableLogging,
setLogLevel,
LogLevel,
configureLogger,
getLogs,
isSensorAvailable
} from '@sbaiahmed1/react-native-biometrics';
// Enable logging with INFO level
enableLogging(true);
setLogLevel(LogLevel.INFO);
// Configure advanced logging options
configureLogger({
useColors: true,
prefix: '[MyApp]',
includeTimestamp: true,
includeContext: true,
maxStoredLogs: 1000
});
// Perform biometric operations - they will be automatically logged
const sensorInfo = await isSensorAvailable();
// Retrieve logs for analysis
const logs = getLogs();
console.log('Recent logs:', logs);
For detailed logging documentation, see the Logging Guide.