log method

  1. @override
Future<void> log(
  1. String value, {
  2. String level = 'debug',
})
override

Implementation

@override
Future<void> log(String value, {String level = 'debug'}) async {
  if (isReady) {
    try {
      // Breadcrumb: attached to the next error/transaction event.
      // Visible in the event detail view under "Breadcrumbs".
      // All levels produce breadcrumbs.
      await Sentry.addBreadcrumb(
        Breadcrumb(
          message: value,
          category: 'log',
          level: _toSentryLevel(level),
          timestamp: DateTime.now(),
        ),
      );

      // Sentry Logs: standalone structured log entry visible in the
      // Logs section of the Sentry dashboard.
      // Requires options.enableLogs = true (set via 'enableLogs' in LD config).
      //
      // Only emit standalone Sentry log entries for info+ levels.
      // verbose/debug are breadcrumb-only to avoid millions of
      // standalone log entries from high-frequency code paths.
      if (Sentry.isEnabled &&
          (level == 'info' || level == 'warning')) {
        if (level == 'warning') {
          Sentry.logger.warn(value);
        } else {
          Sentry.logger.info(value);
        }
      }
    } catch (e) {
      _printDebug(
        '$providerName: Failed to log info: $e, trace: ${StackTrace.current}',
      );
    }
  }
}