From 48c46efa42caa22eb5a6881de85b7a020fd1c225 Mon Sep 17 00:00:00 2001 From: Bruno Tremblay Date: Sun, 3 Nov 2024 15:08:23 -0500 Subject: [PATCH] testing --- .github/workflows/R-CMD-check.yaml | 13 --------- src/bqs.cpp | 43 +++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 14 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 7e90ad0..eee2bde 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -21,20 +21,7 @@ jobs: fail-fast: false matrix: config: - - { os: macos-12, r: 'release' } - - { os: macos-13, r: 'release' } - { os: macos-13, r: 'release', deps: 'homebrew' } - - { os: windows-latest, r: '4.0' } - - { os: windows-latest, r: '4.1' } - - { os: windows-latest, r: '4.2' } - - { os: windows-latest, r: 'release' } - - { os: windows-latest, r: 'devel' } - - { os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} - - { os: ubuntu-latest, r: 'release' } - - { os: ubuntu-latest, r: 'oldrel-1' } - - { os: ubuntu-latest, r: 'oldrel-2' } - - { os: ubuntu-latest, r: 'oldrel-3' } - - { os: ubuntu-latest, r: 'oldrel-4' } env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} diff --git a/src/bqs.cpp b/src/bqs.cpp index 02c8c8d..8f3874b 100644 --- a/src/bqs.cpp +++ b/src/bqs.cpp @@ -2,7 +2,19 @@ #include #include #include +#include + +#if GRPC_CPP_VERSION_MAJOR == 1 & GRPC_CPP_VERSION_MINOR <= 66 #include +#endif + +#if GRPC_CPP_VERSION_MAJOR >= 1 & GRPC_CPP_VERSION_MINOR >= 67 +#include +#include +#include +#include +#endif + #include #include "google/cloud/bigquery/storage/v1/stream.pb.h" #include "google/cloud/bigquery/storage/v1/storage.pb.h" @@ -15,27 +27,56 @@ using google::cloud::bigquery::storage::v1::ReadSession; using google::cloud::bigquery::storage::v1::BigQueryRead; // -- Utilities and logging ---------------------------------------------------- - // Define a default logger for gRPC +#if GRPC_CPP_VERSION_MAJOR == 1 & GRPC_CPP_VERSION_MINOR <= 66 void bqs_default_log(gpr_log_func_args* args) { Rcpp::Rcerr << args->message << std::endl; } +#endif + +#if GRPC_CPP_VERSION_MAJOR >= 1 & GRPC_CPP_VERSION_MINOR >= 67 +class RLogSink : public absl::LogSink { +public: + void Send(const absl::LogEntry& entry) override { + Rcpp::Rcerr << entry.text_message_with_prefix_and_newline() << std::endl; + } +}; +#endif // Set gRPC verbosity level // [[Rcpp::export(rng=false)]] void bqs_set_log_verbosity(int severity) { + +#if GRPC_CPP_VERSION_MAJOR == 1 & GRPC_CPP_VERSION_MINOR <= 66 //-1 UNSET // 0 DEBUG // 1 INFO // 2 ERROR // 3 QUIET gpr_set_log_verbosity(static_cast(severity)); +#endif + +#if GRPC_CPP_VERSION_MAJOR >= 1 & GRPC_CPP_VERSION_MINOR >= 67 + // -1 UNSET + // 0 INFO + // 1 WARNING + // 2 ERROR + // 3 FATAL + SetMinLogLevel(static_cast(severity)) +#endif + } // Set gRPC default logger // [[Rcpp::export(rng=false)]] void bqs_init_logger() { +#if GRPC_CPP_VERSION_MAJOR == 1 & GRPC_CPP_VERSION_MINOR <= 66 gpr_set_log_function(bqs_default_log); +#endif +#if GRPC_CPP_VERSION_MAJOR >= 1 & GRPC_CPP_VERSION_MINOR >= 67 + static absl::NoDestructor r_log_sink; + AddLogSink(r_log_sink.get()) +#endif bqs_set_log_verbosity(2); }