Skip to content

Commit

Permalink
testing
Browse files Browse the repository at this point in the history
  • Loading branch information
meztez committed Nov 3, 2024
1 parent 73844dd commit 48c46ef
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 14 deletions.
13 changes: 0 additions & 13 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
43 changes: 42 additions & 1 deletion src/bqs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,19 @@
#include <string>
#include <vector>
#include <grpc/grpc.h>
#include <grpcpp/version_info.h>

#if GRPC_CPP_VERSION_MAJOR == 1 & GRPC_CPP_VERSION_MINOR <= 66
#include <grpc/support/log.h>
#endif

#if GRPC_CPP_VERSION_MAJOR >= 1 & GRPC_CPP_VERSION_MINOR >= 67
#include <absl/log/globals.h>
#include <absl/log/initialize.h>
#include <absl/log/log_sink_registry.h>
#include <absl/log/log_sink.h>
#endif

#include <grpcpp/grpcpp.h>
#include "google/cloud/bigquery/storage/v1/stream.pb.h"
#include "google/cloud/bigquery/storage/v1/storage.pb.h"
Expand All @@ -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<gpr_log_severity>(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<absl::LogSeverity>(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<RLogSink> r_log_sink;
AddLogSink(r_log_sink.get())
#endif
bqs_set_log_verbosity(2);
}

Expand Down

0 comments on commit 48c46ef

Please sign in to comment.