log method
Logs message
with log level
and optional tag
, ex
(exception) stacktrace
Implementation
@override
void log(String level, String message, {String? tag, dynamic ex, StackTrace? stacktrace}) {
if (excludes.any((e) => message.contains(e))) return;
if (skipCloneErrors > 0) {
final text = '$message $stacktrace';
if (_lastErrors.contains(text)) return;
if (_lastErrors.length >= skipCloneErrors) {
_lastErrors.removeRange(skipCloneErrors, _lastErrors.length);
}
_lastErrors.insert(0, text);
}
if (!kIsWeb) {
FirebaseCrashlytics.instance.setCustomKey('priority', _priorities[level] ?? 0);
FirebaseCrashlytics.instance.recordError('[$level] $message', stacktrace);
FirebaseCrashlytics.instance.setCustomKey('priority', -1);
}
if (!message.contains('failed to connect to yandex')) {
unawaited(DSMetrica.reportError(
message: '[$level] $message',
errorDescription: stacktrace != null
? AppMetricaErrorDescription(stacktrace, message: message, type: '[$level]')
: null,
));
unawaited(Sentry.captureException(
ex ?? '[$level] $message',
stackTrace: stacktrace,
withScope: (scope) {
scope.setTag('user_id_metrica', DSMetrica.yandexId);
},
));
final limStack = LimitedStackTrace(
stackTrace: stacktrace ?? StackTrace.empty,
deep: 4,
);
DSMetrica.reportEvent('[$level] $message', attributes: {
'error_priority': _priorities[level] ?? 0,
'stack': '$limStack',
});
}
}