DVLogShipper.toBackend constructor

DVLogShipper.toBackend({
  1. required Uri endpoint(),
  2. required String installId,
  3. required String release,
  4. required String platform,
  5. DVLogLevel level = DVLogLevel.warn,
  6. int batch = 50,
  7. Client? client,
  8. Duration timeout = const Duration(seconds: 15),
})

Posts to the application's own backend at endpoint, read at send time so the runtime's base URL is the one in force.

Implementation

factory DVLogShipper.toBackend({
  required Uri Function() endpoint,
  required String installId,
  required String release,
  required String platform,
  DVLogLevel level = DVLogLevel.warn,
  int batch = 50,
  http.Client? client,
  Duration timeout = const Duration(seconds: 15),
}) =>
    DVLogShipper(
      post: (String body) async {
        final http.Client sending = client ?? http.Client();
        try {
          final http.Response response = await sending
              .post(endpoint(),
                  headers: const <String, String>{
                    'content-type': 'application/json; charset=utf-8',
                  },
                  body: body)
              .timeout(timeout);
          return response.statusCode;
        } finally {
          if (client == null) sending.close();
        }
      },
      installId: installId,
      release: release,
      platform: platform,
      level: level,
      batch: batch,
    );