lmLog function

dynamic lmLog(
  1. dynamic message, {
  2. int level = 0,
})

Implementation

lmLog(dynamic message, {int level = 0}) async {
  try {
    if (kDebugMode) {
      print(message);
    }
    if (level > 0) {
      var client = http.Client();
      String url = IvivaAccount().getAccountPath("/hook/LucyMobile/log");
      http.Response res = await client.post(Uri.parse(url),
          headers: {'Content-Type': 'application/json'},
          body: jsonEncode({
            "log": {
              "error": message.toString(),
              "user": (AuthRepository().loggedInUser?.email ??
                  "user not logged in"),
            }.toString()
          }));
      if (kDebugMode) {
        print(res.body);
      }
    }
  } catch (e) {
    if (kDebugMode) {
      print(e);
    }
  }
}