setLogLevel method
- TrustPinLogLevel level
Sets the current log level for this TrustPin instance's logging system.
Logging helps with debugging certificate pinning issues and monitoring security events. Different log levels provide varying amounts of detail.
Log Levels
- TrustPinLogLevel.none: No logging output
- TrustPinLogLevel.error: Only error messages
- TrustPinLogLevel.info: Errors and informational messages
- TrustPinLogLevel.debug: All messages including detailed debug information
Example Usage
// Enable debug logging for development
await TrustPin.shared.setLogLevel(TrustPinLogLevel.debug);
// Minimal logging for production
await TrustPin.shared.setLogLevel(TrustPinLogLevel.error);
// Disable all logging
await TrustPin.shared.setLogLevel(TrustPinLogLevel.none);
Performance Considerations
-
Production: Use TrustPinLogLevel.error or TrustPinLogLevel.none to minimize performance impact
-
Development: Use TrustPinLogLevel.debug for detailed troubleshooting information
-
Staging: Use TrustPinLogLevel.info for balanced logging without excessive detail
-
Parameter
level: The TrustPinLogLevel to use for filtering log messages -
Note: This setting affects logging for this instance only.
-
Important: Set the log level before calling setup for complete logging coverage.
Implementation
Future<void> setLogLevel(TrustPinLogLevel level) async {
try {
await TrustPinSDKPlatform.instance
.setLogLevel(level.value, instanceId: _instanceId);
} catch (e) {
throw TrustPinException.fromPlatformException(e);
}
}