Skip to main content

Logging

info

TeadsLog controls the plugin's Dart-side logging. It is quiet by default — you see warnings and errors, not a stream of diagnostics you never asked for.

Log Levels​

enum LogLevel { none, error, warn, info, debug }

Setting TeadsLog.level shows that level and everything less verbose than it:

LevelShowsUse for
nonenothingSilencing the SDK completely
errorerrorsProduction, if you want failures only
warnerrors + warningsThe default
info+ lifecycle eventsVerifying an integration works
debug+ fine-grained tracingDiagnosing a specific problem
// While developing:
TeadsLog.level = LogLevel.debug;

// Silence entirely:
TeadsLog.level = LogLevel.none;

Set it once, wherever you configure the SDK:

Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
if (kDebugMode) {
TeadsLog.level = LogLevel.debug;
}
await TeadsSdk.configure('YOUR_APP_KEY');
runApp(const MyApp());
}

Default Output​

Lines print via debugPrint, tagged with the component that emitted them:

[Feed] debug: bridge URL built for widgetId=MB_1
[Recommendations] info: fetch: got 8 recommendation(s) for widgetId=SDK_1
[Interstitial] error: interstitial.create failed — PlatformException(...)

Tags include Feed, Banner, Interstitial, Recommendations and RecommendationsViewability, which makes filtering easy.

Routing Logs Into Your Own Pipeline​

Assign a sink to send SDK logs wherever your app's logs already go — Crashlytics, Sentry, Datadog, your own logger:

typedef TeadsLogSink = void Function(
LogLevel level,
String tag,
String message,
Object? error,
StackTrace? stackTrace,
);
TeadsLog.sink = (level, tag, message, error, stackTrace) {
MyLogger.log(
level: _mapLevel(level),
message: '[Teads/$tag] $message',
error: error,
stackTrace: stackTrace,
);
};

The sink is only called for lines that already passed the level filter. error and stackTrace are non-null only for error-level calls that were given them.

Reporting SDK errors to crash reporting​

TeadsLog.sink = (level, tag, message, error, stackTrace) {
if (level == LogLevel.error && error != null) {
FirebaseCrashlytics.instance.recordError(
error,
stackTrace,
reason: '[Teads/$tag] $message',
fatal: false,
);
}
if (kDebugMode) {
debugPrint('[Teads/$tag] ${level.name}: $message');
}
};
Replacing the sink replaces the default

Assigning a sink stops the default debugPrint output. Call debugPrint from your own sink if you still want console lines, as above.

Native Logs​

TeadsLog covers the plugin's Dart side only. The native SDKs log separately, and TeadsLog.level does not affect them:

Android

adb logcat | grep -i teads

iOS

Open the Xcode console and filter for Teads.

Why Dart-side only

Neither native SDK exposes a logging contract worth plumbing through: Android's is internal-only with no interception point, and iOS's covers only WebView console output with no level control and no Android counterpart. Building this in Dart keeps diagnostics identical on both platforms.

Debugging Checklist​

When a placement is not behaving:

  1. TeadsLog.level = LogLevel.debug
  2. Look for an error-level line from the relevant tag
  3. For Feed, make sure onUnsupported is wired up — page-reported problems arrive there, not in the log
  4. Check the native logs too, for the wrapped placements (Media, Banner, Interstitial)
  5. Confirm TeadsSdk.configure() did not throw

Production Recommendations​

  • Leave the level at its default (warn), or set error
  • Do not ship LogLevel.debug — it is verbose and can include request details
  • Route errors to your crash reporter so no-fill and failure patterns are visible
  • Never log full consent strings in a production build
TeadsLog.level = kDebugMode ? LogLevel.debug : LogLevel.error;