resolveLogDestiny method

MessageLogger? resolveLogDestiny(
  1. Object? logDestiny
)

Implementation

MessageLogger? resolveLogDestiny(final Object? logDestiny) {
  if (logDestiny == null) return null;

  if (logDestiny is Map) {
    var destiny =
        logDestiny['to'] ?? logDestiny['path'] ?? logDestiny['file'];
    if (destiny != null) {
      return resolveLogDestiny(destiny);
    }
  }

  if (logDestiny is MessageLogger) return logDestiny;

  if (logDestiny == 'console' || logDestiny == 'stdout') {
    return printMessage;
  }

  if (logDestiny is Function(Object, Object)) {
    return (l, m) => logDestiny(l, m);
  } else if (logDestiny is Function(dynamic, dynamic)) {
    return (l, m) => logDestiny(l, m);
  }

  if (logDestiny is Function(Object)) {
    return (l, m) => logDestiny(m);
  } else if (logDestiny is Function(dynamic)) {
    return (l, m) => logDestiny(m);
  }

  if (logDestiny is HttpClient) {
    return (l, m) async => _logToHttpClient(logDestiny, l, m);
  }

  return null;
}