File tree 7 files changed +174
-177
lines changed
7 files changed +174
-177
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,8 @@ bool isStatusCancelled(int status) noexcept {
23
23
return status == ::grpc::StatusCode::CANCELLED;
24
24
}
25
25
26
+ void set_name (...) {} // NOLINT(cert-dcl50-cpp)
27
+
26
28
} // namespace client_helper_details
27
29
28
30
ClientContext::ClientContext () : wrapped_context_(std::make_unique<GrpcClientContext>()) {
Original file line number Diff line number Diff line change @@ -15,6 +15,19 @@ namespace client_helper_details {
15
15
// Helper function to test equality of status with grpc::StatusCode::CANCELLED.
16
16
bool isStatusCancelled (int status) noexcept ;
17
17
18
+ // Set the mutable name of a request to the client name.
19
+ // This function only participates in overload resolution if the request has a mutable_name method.
20
+ template <typename RequestType,
21
+ typename ClientType,
22
+ typename = decltype(&RequestType::mutable_name)>
23
+ void set_name (RequestType* req, const ClientType* client) {
24
+ *req->mutable_name () = client->name ();
25
+ }
26
+
27
+ // No-op version of set_name above. This overload is only selected if the request type does not have
28
+ // a mutable_name field.
29
+ void set_name (...);
30
+
18
31
} // namespace client_helper_details
19
32
20
33
// the authority on a grpc::ClientContext is sometimes set to an invalid uri on mac, causing
@@ -96,7 +109,7 @@ class ClientHelper {
96
109
97
110
template <typename ResponseHandlerCallable, typename ErrorHandlerCallable>
98
111
auto invoke (ResponseHandlerCallable&& rhc, ErrorHandlerCallable&& ehc) {
99
- *request_. mutable_name () = client_-> name ( );
112
+ client_helper_details::set_name (&request_, client_);
100
113
ClientContext ctx;
101
114
102
115
if (debug_key_ != " " ) {
Original file line number Diff line number Diff line change @@ -133,11 +133,15 @@ void LogManager::init_logging() {
133
133
console_sink_ = boost::make_shared<
134
134
boost::log ::sinks::synchronous_sink<boost::log ::sinks::text_ostream_backend>>(backend);
135
135
136
- console_sink_->set_filter (Filter{this });
136
+ boost::log::core::get ()->add_sink (console_sink_);
137
+
137
138
console_sink_->set_formatter (fmt);
139
+ enable_console_logging ();
140
+ }
138
141
139
- boost::log::core::get ()->add_sink (console_sink_);
140
- VIAM_SDK_LOG (debug) << " Initialized console logging" ;
142
+ void LogManager::enable_console_logging () {
143
+ console_sink_->set_filter (Filter{this });
144
+ VIAM_SDK_LOG (debug) << " Console logging enabled" ;
141
145
}
142
146
143
147
void LogManager::disable_console_logging () {
Original file line number Diff line number Diff line change @@ -113,6 +113,7 @@ class LogManager {
113
113
LogManager& operator =(LogManager&&) = delete ;
114
114
115
115
void init_logging ();
116
+ void enable_console_logging ();
116
117
void disable_console_logging ();
117
118
118
119
LogSource sdk_logger_;
You can’t perform that action at this time.
0 commit comments