groveman_sentry 1.0.4 groveman_sentry: ^1.0.4 copied to clipboard
Groveman tree that sends its logs to Sentry.io through Breadcrumbs and events capture.
Groveman Sentry #
Tree for the groveman.
It sends your logs to the Sentry.
This works perfectly with sentry-dart and sentry-flutter 🙌
Usage #
Add it in your pubspec.yaml
:
dependencies:
groveman:
groveman_sentry:
sentry:
// or
sentry_flutter:
Import it where you want to use it e.g, in your main file.
import 'package:groveman/groveman.dart';
import 'package:groveman_sentry/groveman_sentry.dart';
Initialize Sentry and plant the SentryTree
at the start of your application.
import 'package:flutter/widgets.dart';
import 'package:groveman/groveman.dart';
import 'package:groveman_sentry/groveman_sentry.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
void main() {
Groveman.plantTree(DebugTree());
Groveman.captureErrorInZone(() async {
WidgetsFlutterBinding.ensureInitialized();
await SentryFlutter.init(
(options) {
options.dsn = 'https://example@sentry.io/add-your-dsn-here';
},
);
if (kReleaseMode) {
Groveman.plantTree(SentryTree());
}
Groveman.captureErrorInCurrentIsolate();
runApp(const MyApp());
});
}
Usually, you only send your logs in production.
By default, the log levels info
, warning
, error
, and fatal
are sent to Sentry.
Groveman.error(message, error: exception);
If the LogRecord.error
is not null, it will be sent using captureEvent
, otherwise, is used addBreadcrumb.
LogRecord
converted in SentryEvent:
LogRecord.level
-> SentryLevelLogRecord.message
-> SentryMessage(message)LogRecord.extra
-> extraLogRecord.error
-> throwableLogRecord.tag
-> tags
groveman
is sent as logger in SentryEvent
.
The LogRecord.stackTrace
is only sent in captureEvent
.
LogRecord
converted in Breadcrumb:
LogRecord.level
-> SentryLevelLogRecord.message
-> messageLogRecord.extra
-> data
To custom, pass the levels that desire to send when creating the SentryTree
.
Groveman.plantTree(
SentryTree(logLevels: [
LogLevel.warning,
LogLevel.info,
]),
);
);
📝 License #
Copyright © 2022 Kauê Martins
This project is MIT licensed