GoogleLogger constructor

GoogleLogger({
  1. required String projectId,
  2. String? serviceAccount,
  3. AutoRefreshingAuthClient? client,
})

Implementation

GoogleLogger({
  required this.projectId,
  String? serviceAccount,
  AutoRefreshingAuthClient? client,
}) {
  if (client is AutoRefreshingAuthClient) {
    _httpClient = client;
    _logger = LoggingApi(_httpClient!);
  } else if (serviceAccount is String) {
    try {
      String base64String = serviceAccount;
      if (isBase64(serviceAccount)) {
        final base64List = base64Decode(
          serviceAccount,
        );
        base64String = utf8.decode(
          base64List,
        );
      }
      clientViaServiceAccount(
          ServiceAccountCredentials.fromJson(base64String), [
        LoggingApi.loggingWriteScope,
      ]).then((value) {
        _httpClient = value;
        _logger = LoggingApi(_httpClient!);
      }).catchError((err) {
        debugPrint(err.toString());
      });
    } catch (err) {
      debugPrint(err.toString());
    }
  }
}