invokeLogger method

  1. @override
Future<RequestResponse<FrappeLog?>> invokeLogger({
  1. String? cmd,
  2. String? content,
  3. String? title,
  4. List<String>? tags,
  5. String? request,
  6. String? response,
})

A wrapper fn for backend endpoint

Implementation

@override
Future<RequestResponse<FrappeLog?>> invokeLogger(
    {String? cmd,
    String? content,
    String? title,
    List<String>? tags,
    String? request,
    String? response}) async {
  await getFrappe().checkAppInstalled(features: ['Logger']);

  tags ?? _defaultTags;

  final logResponse = await config.coreInstance.call(<String, dynamic>{
    'cmd': cmd,
    'content': content,
    'title': title,
    'tags': tags != null ? json.encode(tags) : null,
    'request': request,
    'response': response
  });

  if (logResponse.isSuccess) {
    List<dynamic>? tagsDoc = logResponse.data!.message['tags'];
    if (logResponse.data!.message != null && tagsDoc != null) {
      final tags = tagsDoc.map<String?>((dynamic x) => x['tag']).toList();

      logResponse.data!.message.addAll({'tags_list': tags});
    }
    return RequestResponse.success<FrappeLog>(
        FrappeLog.fromJson(logResponse.data!.message),
        rawResponse: logResponse.rawResponse);
  } else {
    return RequestResponse.fail(handleError(null, logResponse.error!));
  }
}