enableLogForwarding static method

Future<bool> enableLogForwarding(
  1. void listener(
    1. String level,
    2. String message
    )
)

Forwards the SDK's client-facing log lines to listener so they appear in the console a Flutter developer actually uses.

These lines already reach adb logcat on Android and the Xcode console on iOS, but flutter run shows only Dart output — so without this they are invisible from where you are working. On iOS some of them go only to standard output, so Console.app and idevicesyslog miss them too.

listener receives (level, message) where level is one of error, warn, info, debug — the same severities the native logs carry. Filtering follows setLogLevel. Idempotent.

Returns false if the native side does not support forwarding, rather than failing silently.

await VideoSDK.enableLogForwarding((level, message) {
  debugPrint('[$level] $message');
});

Implementation

static Future<bool> enableLogForwarding(
  void Function(String level, String message) listener,
) async {
  NativeBackend.listenForLogs(listener);
  try {
    final ok = await _channel.invokeMethod<bool>('enableLogForwarding');
    if (ok != true) await NativeBackend.stopListeningForLogs();
    return ok ?? false;
  } catch (_) {
    await NativeBackend.stopListeningForLogs();
    return false;
  }
}