Skip to main content
Version: 5.x.x

Log Forwarding - Flutter

The SDK writes its logs to Logcat on Android and to the Xcode console on iOS. flutter run shows only Dart output, so these logs do not appear there. This page shows how to send the logs to your own code, for example to keep the last lines for a bug report, and how to find the SDK version and build to include in that report.

To choose how much the SDK logs, use VideoSDK.setLogLevel().

Forward logs to your app​

VideoSDK.enableLogForwarding() sends the SDK's log lines to a function of your own, in addition to Logcat or the Xcode console.

  • Your function receives the level of each line, one of error, warn, info or debug, and its message.
  • It receives the lines that pass the level you set with setLogLevel().
  • Forwarding covers the whole app, not one room. Turn it on early, for example before you create the room, so that it also covers joining.
  • Calling it again replaces your function. VideoSDK.disableLogForwarding() stops forwarding.
  • It returns false when forwarding could not be turned on.

The example below keeps the last 200 lines, so that your app can attach them to a bug report:

import 'dart:collection';

import 'package:flutter/foundation.dart';
import 'package:videosdk/videosdk.dart';

class SdkLogBuffer {
static final ListQueue<String> _lines = ListQueue<String>();

static Future<void> start() async {
VideoSDK.setLogLevel(LogLevel.DEBUG);

final bool forwarding = await VideoSDK.enableLogForwarding((level, message) {
_lines.addLast("[$level] $message");
if (_lines.length > 200) _lines.removeFirst();
});

if (!forwarding) {
debugPrint("Log forwarding is not available");
}
}

static Future<void> stop() => VideoSDK.disableLogForwarding();

static List<String> lines() => List<String>.unmodifiable(_lines);
}

Find the SDK version and build​

Include the SDK version and build when you report an issue, and consider showing them on an about or debug screen.

  • VideoSDK.sdkVersion returns the version of the Flutter SDK, as in its pubspec.yaml.
  • VideoSDK.getBuildId() returns the build of the Android or iOS SDK that the Flutter SDK runs on. Two apps on the same Flutter SDK version can run different builds. It returns unknown when the platform does not report one.
import 'package:videosdk/videosdk.dart';

Future<String> sdkInfo() async {
final String buildId = await VideoSDK.getBuildId();
return "VideoSDK ${VideoSDK.sdkVersion}, build $buildId";
}

What to include in a bug report​

  • The SDK version and build, from the section above.
  • The device model, and the Android or iOS version.
  • The room id, and the time the problem happened.
  • The SDK's log lines at LogLevel.DEBUG, from a few seconds before the problem to after it.
  • The code and name of any VideoSDKError or error event you received.

API Reference​

The API references for all the methods utilized in this guide are provided below.

Got a Question? Ask us on discord