简体   繁体   中英

How to send print log from flutter app?

如何获取print控制台日志和屏幕截图,以便我可以将堆栈跟踪发送到服务器?

You can get a screenshot of the FlutterView using native code.

  • On Android: Bitmap screenshot = flutterView.getBitmap();
  • On iOS, see this example from Apple.

See the platform channels documentation on mixing Dart and native code.

As for the stack trace, here are some tips from the Flutter Sentry library documentation.

To get a stack trace from within Flutter, override the onError handler:

FlutterError.onError = (FlutterErrorDetails details) async {
  throw details;
};

To create a Zone with an error handler that catches all Dart exceptions, wrap your call to runApp in runZoned :

runZoned<Future<Null>>(() async {
  runApp(new MyApp());
}, onError: (error, stackTrace) async {
  if (error is FlutterErrorDetails) {
    // use error.exception and error.stack
  } else {
    // use error and stackTrace
  }
});

you can use f_logs package, this has a functionality on export logs to a directory on the phone, it has .db and .txt for the logs, and then you can use flutter_archive package to zip the file, and then use flutter_email_sender to send the zip file that contains the logs your development team. It worked for us, hope this will helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM