setLogLevel static method
- TrustPinLogLevel level
Sets the current log level for TrustPin's internal 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.setLogLevel(TrustPinLogLevel.debug);
// Minimal logging for production
await TrustPin.setLogLevel(TrustPinLogLevel.error);
// Disable all logging
await TrustPin.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 all TrustPin logging globally across your application.
-
Important: Set the log level before calling setup for complete logging coverage.
Implementation
static Future<void> setLogLevel(TrustPinLogLevel level) async {
try {
await TrustPinSDKPlatform.instance.setLogLevel(level.value);
} catch (e) {
throw TrustPinException.fromPlatformException(e);
}
}