onLogEvent method

Future<void> onLogEvent(
  1. LogEvent event,
  2. Emitter emit
)

Implementation

Future<void> onLogEvent(LogEvent event, Emitter emit) async {
  try {
    final serverUrl = getServerUrl();
    final body = json.safeEncode(EditorMessage("log", {
      "origin": "client",
      "type": event.type,
      "message": event.message,
      "context": event.context,
      "error": event.error?.toString(),
      "stackTrace": event.stackTrace?.toString(),
    }));
    await http.post(Uri.parse(serverUrl), body: body);
  } catch (e, stack) {
    _log.severe("Error sending log to Editor: $e", e, stack);
  }
}