mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
Replace NEARBY_LOGS with LOG for all coding under google3/third_party/nearby/
PiperOrigin-RevId: 786733783
This commit is contained in:
@@ -41,15 +41,15 @@ void NearbyHttpClient::StartRequest(
|
||||
MutexLock lock(&mutex_);
|
||||
executor_.Execute(
|
||||
[request = std::move(request), callback = std::move(callback)]() mutable {
|
||||
NEARBY_LOGS(INFO) << __func__ << ": Start async request to url="
|
||||
LOG(INFO) << __func__ << ": Start async request to url="
|
||||
<< request.GetUrl().GetUrlPath();
|
||||
absl::StatusOr<HttpResponse> response = InternalGetResponse(request);
|
||||
if (response.ok()) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< __func__
|
||||
<< ": Got response from url=" << request.GetUrl().GetUrlPath();
|
||||
} else {
|
||||
NEARBY_LOGS(ERROR) << __func__ << ": Failed to get response from url="
|
||||
LOG(ERROR) << __func__ << ": Failed to get response from url="
|
||||
<< request.GetUrl().GetUrlPath() << ", status"
|
||||
<< response.status();
|
||||
}
|
||||
@@ -57,7 +57,7 @@ void NearbyHttpClient::StartRequest(
|
||||
if (callback) {
|
||||
callback(response);
|
||||
}
|
||||
NEARBY_LOGS(INFO) << __func__ << ": Completed request to url="
|
||||
LOG(INFO) << __func__ << ": Completed request to url="
|
||||
<< request.GetUrl().GetUrlPath();
|
||||
});
|
||||
}
|
||||
@@ -67,7 +67,7 @@ void NearbyHttpClient::StartCancellableRequest(
|
||||
absl::AnyInvocable<void(const absl::StatusOr<HttpResponse>&)> callback) {
|
||||
MutexLock lock(&mutex_);
|
||||
if (cancellable_request == nullptr) {
|
||||
NEARBY_LOGS(ERROR) << __func__ << ": invalid cancellable request.";
|
||||
LOG(ERROR) << __func__ << ": invalid cancellable request.";
|
||||
callback(absl::InvalidArgumentError("invalid cancellable request"));
|
||||
return;
|
||||
}
|
||||
@@ -75,11 +75,11 @@ void NearbyHttpClient::StartCancellableRequest(
|
||||
.Execute(
|
||||
[cancellable_request = std::move(cancellable_request),
|
||||
callback = std::move(callback)]() mutable {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< __func__ << ": Start async request to url="
|
||||
<< cancellable_request->http_request().GetUrl().GetUrlPath();
|
||||
if (cancellable_request->is_cancelled()) {
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< __func__ << ": Async request to url="
|
||||
<< cancellable_request->http_request().GetUrl().GetUrlPath()
|
||||
<< " is cancelled.";
|
||||
@@ -88,18 +88,18 @@ void NearbyHttpClient::StartCancellableRequest(
|
||||
absl::StatusOr<HttpResponse> response =
|
||||
InternalGetResponse(cancellable_request->http_request());
|
||||
if (response.ok()) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< __func__ << ": Got response from url="
|
||||
<< cancellable_request->http_request().GetUrl().GetUrlPath();
|
||||
} else {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< __func__ << ": Failed to get response from url="
|
||||
<< cancellable_request->http_request().GetUrl().GetUrlPath()
|
||||
<< ", status" << response.status();
|
||||
}
|
||||
|
||||
if (cancellable_request->is_cancelled()) {
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< __func__ << ": Async request to url="
|
||||
<< cancellable_request->http_request().GetUrl().GetUrlPath()
|
||||
<< " is cancelled.";
|
||||
@@ -109,7 +109,7 @@ void NearbyHttpClient::StartCancellableRequest(
|
||||
if (callback) {
|
||||
callback(response);
|
||||
}
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< __func__ << ": Completed request to url="
|
||||
<< cancellable_request->http_request().GetUrl().GetUrlPath();
|
||||
});
|
||||
@@ -117,15 +117,15 @@ void NearbyHttpClient::StartCancellableRequest(
|
||||
|
||||
absl::StatusOr<HttpResponse> NearbyHttpClient::GetResponse(
|
||||
const HttpRequest& request) {
|
||||
NEARBY_LOGS(INFO) << __func__ << ": Start request to url="
|
||||
LOG(INFO) << __func__ << ": Start request to url="
|
||||
<< request.GetUrl().GetUrlPath();
|
||||
|
||||
absl::StatusOr<HttpResponse> response = InternalGetResponse(request);
|
||||
if (response.ok()) {
|
||||
NEARBY_LOGS(INFO) << __func__ << ": Got response from url="
|
||||
LOG(INFO) << __func__ << ": Got response from url="
|
||||
<< request.GetUrl().GetUrlPath();
|
||||
} else {
|
||||
NEARBY_LOGS(ERROR) << __func__ << ": Failed to get response from url="
|
||||
LOG(ERROR) << __func__ << ": Failed to get response from url="
|
||||
<< request.GetUrl().GetUrlPath() << ", status"
|
||||
<< response.status();
|
||||
}
|
||||
@@ -155,7 +155,7 @@ absl::StatusOr<HttpResponse> NearbyHttpClient::InternalGetResponse(
|
||||
request_stream << std::endl;
|
||||
request_stream << "body size: " << request.GetBody().GetRawData().size()
|
||||
<< std::endl;
|
||||
NEARBY_VLOG(1) << request_stream.str();
|
||||
VLOG(1) << request_stream.str();
|
||||
}
|
||||
|
||||
absl::StatusOr<api::WebResponse> web_response =
|
||||
@@ -176,7 +176,7 @@ absl::StatusOr<HttpResponse> NearbyHttpClient::InternalGetResponse(
|
||||
}
|
||||
response_stream << std::endl;
|
||||
response_stream << "body size: " << web_response->body.size() << std::endl;
|
||||
NEARBY_VLOG(1) << response_stream.str();
|
||||
VLOG(1) << response_stream.str();
|
||||
}
|
||||
|
||||
HttpResponse response;
|
||||
|
||||
@@ -43,7 +43,7 @@ class ArrayBlockingQueue {
|
||||
has_space_.Wait();
|
||||
}
|
||||
queue_.push(value);
|
||||
NEARBY_LOGS(INFO) << "ArrayBlockingQueue::Put()";
|
||||
LOG(INFO) << "ArrayBlockingQueue::Put()";
|
||||
has_data_.Notify();
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ class ArrayBlockingQueue {
|
||||
}
|
||||
T front = queue_.front();
|
||||
queue_.pop();
|
||||
NEARBY_LOGS(INFO) << "ArrayBlockingQueue::Take()";
|
||||
LOG(INFO) << "ArrayBlockingQueue::Take()";
|
||||
has_space_.Notify();
|
||||
return front;
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ class AwdlSocket : public MediumSocket {
|
||||
// Returns Exception::kIo on error, Exception::kSuccess otherwise.
|
||||
Exception Close() override {
|
||||
if (IsVirtualSocket()) {
|
||||
NEARBY_LOGS(INFO) << "Multiplex: Closing virtual socket: " << this;
|
||||
LOG(INFO) << "Multiplex: Closing virtual socket: " << this;
|
||||
blocking_queue_input_stream_->Close();
|
||||
virtual_output_stream_->Close();
|
||||
CloseLocal(); // This will trigger MultiplexSocket::OnVirtualSocketClosed
|
||||
@@ -106,7 +106,7 @@ class AwdlSocket : public MediumSocket {
|
||||
/** Feeds the received incoming data to the client. */
|
||||
void FeedIncomingData(ByteArray data) override {
|
||||
if (!IsVirtualSocket()) {
|
||||
NEARBY_LOGS(INFO) << "Feeding data on a physical socket is not allowed.";
|
||||
LOG(INFO) << "Feeding data on a physical socket is not allowed.";
|
||||
return;
|
||||
}
|
||||
blocking_queue_input_stream_->Write(data);
|
||||
@@ -166,7 +166,7 @@ class AwdlServerSocket final {
|
||||
AwdlSocket Accept() {
|
||||
std::unique_ptr<api::AwdlSocket> socket = impl_->Accept();
|
||||
if (!socket) {
|
||||
NEARBY_LOGS(INFO) << "AwdlServerSocket Accept() failed on server socket: "
|
||||
LOG(INFO) << "AwdlServerSocket Accept() failed on server socket: "
|
||||
<< this;
|
||||
}
|
||||
return AwdlSocket(std::move(socket));
|
||||
@@ -174,7 +174,7 @@ class AwdlServerSocket final {
|
||||
|
||||
// Returns Exception::kIo on error, Exception::kSuccess otherwise.
|
||||
Exception Close() {
|
||||
NEARBY_LOGS(INFO) << "AwdlServerSocket Closing:: " << this;
|
||||
LOG(INFO) << "AwdlServerSocket Closing:: " << this;
|
||||
return impl_->Close();
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ bool BleMedium::StartScanning(
|
||||
if (peripherals_.empty()) return;
|
||||
auto context = peripherals_.find(&peripheral);
|
||||
if (context == peripherals_.end()) return;
|
||||
NEARBY_LOGS(INFO) << "Removing peripheral="
|
||||
LOG(INFO) << "Removing peripheral="
|
||||
<< context->second->peripheral.GetName()
|
||||
<< ", impl=" << &peripheral;
|
||||
discovered_peripheral_callback_.peripheral_lost_cb(
|
||||
@@ -83,7 +83,7 @@ bool BleMedium::StopScanning(const std::string& service_id) {
|
||||
MutexLock lock(&mutex_);
|
||||
discovered_peripheral_callback_ = {};
|
||||
peripherals_.clear();
|
||||
NEARBY_LOGS(INFO) << "Ble Scanning disabled: impl=" << &GetImpl();
|
||||
LOG(INFO) << "Ble Scanning disabled: impl=" << &GetImpl();
|
||||
}
|
||||
return impl_->StopScanning(service_id);
|
||||
}
|
||||
@@ -102,11 +102,11 @@ bool BleMedium::StartAcceptingConnections(const std::string& service_id,
|
||||
&socket, std::make_unique<AcceptedConnectionInfo>());
|
||||
auto& context = *pair.first->second;
|
||||
if (!pair.second) {
|
||||
NEARBY_LOGS(INFO) << "Accepting (again) socket=" << &context.socket
|
||||
LOG(INFO) << "Accepting (again) socket=" << &context.socket
|
||||
<< ", impl=" << &socket;
|
||||
} else {
|
||||
context.socket = BleSocket(&socket);
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Accepting socket=" << &context.socket << ", impl=" << &socket;
|
||||
}
|
||||
if (accepted_connection_callback_) {
|
||||
@@ -120,7 +120,7 @@ bool BleMedium::StopAcceptingConnections(const std::string& service_id) {
|
||||
MutexLock lock(&mutex_);
|
||||
accepted_connection_callback_ = nullptr;
|
||||
sockets_.clear();
|
||||
NEARBY_LOGS(INFO) << "Ble accepted connection disabled: impl="
|
||||
LOG(INFO) << "Ble accepted connection disabled: impl="
|
||||
<< &GetImpl();
|
||||
}
|
||||
return impl_->StopAcceptingConnections(service_id);
|
||||
@@ -131,7 +131,7 @@ BleSocket BleMedium::Connect(BlePeripheral& peripheral,
|
||||
CancellationFlag* cancellation_flag) {
|
||||
{
|
||||
MutexLock lock(&mutex_);
|
||||
NEARBY_LOGS(INFO) << "BleMedium::Connect: peripheral="
|
||||
LOG(INFO) << "BleMedium::Connect: peripheral="
|
||||
<< peripheral.GetName()
|
||||
<< ",impl=" << &peripheral.GetImpl();
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ TEST_P(BleMediumTest, CanStartAcceptingConnectionsAndConnect) {
|
||||
BlePeripheral& peripheral, const std::string& service_id,
|
||||
const ByteArray& advertisement_bytes,
|
||||
bool fast_advertisement) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Discovered peripheral=" << peripheral.GetName()
|
||||
<< ", impl=" << &peripheral.GetImpl()
|
||||
<< ", fast advertisement=" << fast_advertisement;
|
||||
@@ -90,7 +90,7 @@ TEST_P(BleMediumTest, CanStartAcceptingConnectionsAndConnect) {
|
||||
fast_advertisement_service_uuid);
|
||||
ble_b.StartAcceptingConnections(
|
||||
service_id, [&](BleSocket socket, const std::string& service_id) {
|
||||
NEARBY_LOGS(INFO) << "Connection accepted: socket=" << &socket
|
||||
LOG(INFO) << "Connection accepted: socket=" << &socket
|
||||
<< ", service_id=" << service_id;
|
||||
accepted_latch.CountDown();
|
||||
});
|
||||
@@ -136,7 +136,7 @@ TEST_P(BleMediumTest, CanCancelConnect) {
|
||||
BlePeripheral& peripheral, const std::string& service_id,
|
||||
const ByteArray& advertisement_bytes,
|
||||
bool fast_advertisement) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Discovered peripheral=" << peripheral.GetName()
|
||||
<< ", impl=" << &peripheral.GetImpl()
|
||||
<< ", fast advertisement=" << fast_advertisement;
|
||||
@@ -148,7 +148,7 @@ TEST_P(BleMediumTest, CanCancelConnect) {
|
||||
fast_advertisement_service_uuid);
|
||||
ble_b.StartAcceptingConnections(
|
||||
service_id, [&](BleSocket socket, const std::string& service_id) {
|
||||
NEARBY_LOGS(INFO) << "Connection accepted: socket=" << &socket
|
||||
LOG(INFO) << "Connection accepted: socket=" << &socket
|
||||
<< ", service_id=" << service_id;
|
||||
accepted_latch.CountDown();
|
||||
});
|
||||
|
||||
@@ -74,7 +74,7 @@ void BlockingQueueStream::Write(const ByteArray& bytes) {
|
||||
is_writing_ = true;
|
||||
blocking_queue_.Put(bytes);
|
||||
is_writing_ = false;
|
||||
NEARBY_VLOG(1) << "BlockingQueueStream wrote " << bytes.size() << " bytes";
|
||||
VLOG(1) << "BlockingQueueStream wrote " << bytes.size() << " bytes";
|
||||
}
|
||||
|
||||
Exception BlockingQueueStream::Close() {
|
||||
|
||||
@@ -83,13 +83,13 @@ class BluetoothSocket : public MediumSocket {
|
||||
// Returns Exception::kIo on error, Exception::kSuccess otherwise.
|
||||
Exception Close() override {
|
||||
if (IsVirtualSocket()) {
|
||||
NEARBY_LOGS(INFO) << "Multiplex: Closing virtual socket: " << this;
|
||||
LOG(INFO) << "Multiplex: Closing virtual socket: " << this;
|
||||
blocking_queue_input_stream_->Close();
|
||||
virtual_output_stream_->Close();
|
||||
CloseLocal();
|
||||
return {Exception::kSuccess};
|
||||
}
|
||||
NEARBY_LOGS(INFO) << "Multiplex: Closing physical socket: " << this;
|
||||
LOG(INFO) << "Multiplex: Closing physical socket: " << this;
|
||||
return impl_->Close();
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ class BluetoothSocket : public MediumSocket {
|
||||
/** Feeds the received incoming data to the client. */
|
||||
void FeedIncomingData(ByteArray data) override {
|
||||
if (!IsVirtualSocket()) {
|
||||
NEARBY_LOGS(INFO) << "Feeding data on a physical socket is not allowed.";
|
||||
LOG(INFO) << "Feeding data on a physical socket is not allowed.";
|
||||
return;
|
||||
}
|
||||
blocking_queue_input_stream_->Write(data);
|
||||
@@ -170,7 +170,7 @@ class BluetoothServerSocket final {
|
||||
BluetoothSocket Accept() {
|
||||
auto socket = impl_->Accept();
|
||||
if (!socket) {
|
||||
NEARBY_LOGS(INFO) << "Accept() failed on server socket: " << this;
|
||||
LOG(INFO) << "Accept() failed on server socket: " << this;
|
||||
}
|
||||
return BluetoothSocket(std::move(socket));
|
||||
}
|
||||
@@ -179,7 +179,7 @@ class BluetoothServerSocket final {
|
||||
//
|
||||
// Returns Exception::kIo on error, Exception::kSuccess otherwise.
|
||||
Exception Close() {
|
||||
NEARBY_LOGS(INFO) << "Closing server socket: " << this;
|
||||
LOG(INFO) << "Closing server socket: " << this;
|
||||
return impl_->Close();
|
||||
}
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ TEST_P(BluetoothClassicMediumTest, CanConnectToService) {
|
||||
bt_a_->StartDiscovery(DiscoveryCallback{
|
||||
.device_discovered_cb =
|
||||
[this, &found_latch, &discovered_device](BluetoothDevice& device) {
|
||||
NEARBY_LOGS(INFO) << "Device discovered: " << device.GetName();
|
||||
LOG(INFO) << "Device discovered: " << device.GetName();
|
||||
EXPECT_EQ(device.GetName(), adapter_b_->GetName());
|
||||
discovered_device = &device;
|
||||
found_latch.CountDown();
|
||||
@@ -179,7 +179,7 @@ TEST_P(BluetoothClassicMediumTest, CanCancelConnect) {
|
||||
bt_a_->StartDiscovery(DiscoveryCallback{
|
||||
.device_discovered_cb =
|
||||
[this, &found_latch, &discovered_device](BluetoothDevice& device) {
|
||||
NEARBY_LOGS(INFO) << "Device discovered: " << device.GetName();
|
||||
LOG(INFO) << "Device discovered: " << device.GetName();
|
||||
EXPECT_EQ(device.GetName(), adapter_b_->GetName());
|
||||
discovered_device = &device;
|
||||
found_latch.CountDown();
|
||||
@@ -235,7 +235,7 @@ TEST_F(BluetoothClassicMediumTest, SendData) {
|
||||
bt_a_->StartDiscovery(DiscoveryCallback{
|
||||
.device_discovered_cb =
|
||||
[this, &found_latch, &discovered_device](BluetoothDevice& device) {
|
||||
NEARBY_LOGS(INFO) << "Device discovered: " << device.GetName();
|
||||
LOG(INFO) << "Device discovered: " << device.GetName();
|
||||
EXPECT_EQ(device.GetName(), adapter_b_->GetName());
|
||||
discovered_device = &device;
|
||||
found_latch.CountDown();
|
||||
@@ -282,7 +282,7 @@ TEST_F(BluetoothClassicMediumTest, IoOnClosedSocketReturnsEmpty) {
|
||||
bt_a_->StartDiscovery(DiscoveryCallback{
|
||||
.device_discovered_cb =
|
||||
[this, &found_latch, &discovered_device](BluetoothDevice& device) {
|
||||
NEARBY_LOGS(INFO) << "Device discovered: " << device.GetName();
|
||||
LOG(INFO) << "Device discovered: " << device.GetName();
|
||||
EXPECT_EQ(device.GetName(), adapter_b_->GetName());
|
||||
discovered_device = &device;
|
||||
found_latch.CountDown();
|
||||
@@ -351,13 +351,13 @@ TEST_F(BluetoothClassicMediumTest, CanStartDiscovery) {
|
||||
bt_a_->StartDiscovery(DiscoveryCallback{
|
||||
.device_discovered_cb =
|
||||
[this, &found_latch](BluetoothDevice& device) {
|
||||
NEARBY_LOGS(INFO) << "Device discovered: " << device.GetName();
|
||||
LOG(INFO) << "Device discovered: " << device.GetName();
|
||||
EXPECT_EQ(device.GetName(), adapter_b_->GetName());
|
||||
found_latch.CountDown();
|
||||
},
|
||||
.device_lost_cb =
|
||||
[this, &lost_latch](BluetoothDevice& device) {
|
||||
NEARBY_LOGS(INFO) << "Device lost: " << device.GetName();
|
||||
LOG(INFO) << "Device lost: " << device.GetName();
|
||||
EXPECT_EQ(device.GetName(), adapter_b_->GetName());
|
||||
lost_latch.CountDown();
|
||||
},
|
||||
@@ -386,7 +386,7 @@ TEST_F(BluetoothClassicMediumTest, DiscoveryCallbackAfterStopDiscovery) {
|
||||
.device_discovered_cb =
|
||||
[this, &executor, &found_latch](BluetoothDevice& device) {
|
||||
executor.Execute([&]() {
|
||||
NEARBY_LOGS(INFO) << "Device discovered: " << device.GetName();
|
||||
LOG(INFO) << "Device discovered: " << device.GetName();
|
||||
absl::SleepFor(absl::Milliseconds(500));
|
||||
EXPECT_EQ(device.GetName(), adapter_b_->GetName());
|
||||
found_latch.CountDown();
|
||||
@@ -409,13 +409,13 @@ TEST_F(BluetoothClassicMediumTest, CanStopDiscovery) {
|
||||
bt_a_->StartDiscovery(DiscoveryCallback{
|
||||
.device_discovered_cb =
|
||||
[this, &found_latch](BluetoothDevice& device) {
|
||||
NEARBY_LOGS(INFO) << "Device discovered: " << device.GetName();
|
||||
LOG(INFO) << "Device discovered: " << device.GetName();
|
||||
EXPECT_EQ(device.GetName(), adapter_b_->GetName());
|
||||
found_latch.CountDown();
|
||||
},
|
||||
.device_lost_cb =
|
||||
[this, &lost_latch](BluetoothDevice& device) {
|
||||
NEARBY_LOGS(INFO) << "Device lost: " << device.GetName();
|
||||
LOG(INFO) << "Device lost: " << device.GetName();
|
||||
EXPECT_EQ(device.GetName(), adapter_b_->GetName());
|
||||
lost_latch.CountDown();
|
||||
},
|
||||
@@ -436,7 +436,7 @@ TEST_F(BluetoothClassicMediumTest, CanListenForService) {
|
||||
bt_a_->StartDiscovery(DiscoveryCallback{
|
||||
.device_discovered_cb =
|
||||
[this, &found_latch](BluetoothDevice& device) {
|
||||
NEARBY_LOGS(INFO) << "Device discovered: " << device.GetName();
|
||||
LOG(INFO) << "Device discovered: " << device.GetName();
|
||||
EXPECT_EQ(device.GetName(), adapter_b_->GetName());
|
||||
found_latch.CountDown();
|
||||
},
|
||||
@@ -465,7 +465,7 @@ TEST_F(BluetoothClassicMediumTest, BluetoothPairingSuccess) {
|
||||
CountDownLatch found_latch(1);
|
||||
bt_a_->StartDiscovery(
|
||||
DiscoveryCallback{.device_discovered_cb = [&](BluetoothDevice& device) {
|
||||
NEARBY_LOGS(INFO) << "Device discovered: " << device.GetName();
|
||||
LOG(INFO) << "Device discovered: " << device.GetName();
|
||||
EXPECT_EQ(device.GetName(), adapter_b_->GetName());
|
||||
discovered_device = &device;
|
||||
found_latch.CountDown();
|
||||
@@ -537,7 +537,7 @@ TEST_F(BluetoothClassicMediumTest, BluetoothPairingFailure) {
|
||||
CountDownLatch found_latch(1);
|
||||
bt_a_->StartDiscovery(
|
||||
DiscoveryCallback{.device_discovered_cb = [&](BluetoothDevice& device) {
|
||||
NEARBY_LOGS(INFO) << "Device discovered: " << device.GetName();
|
||||
LOG(INFO) << "Device discovered: " << device.GetName();
|
||||
EXPECT_EQ(device.GetName(), adapter_b_->GetName());
|
||||
discovered_device = &device;
|
||||
found_latch.CountDown();
|
||||
@@ -599,8 +599,8 @@ TEST_F(BluetoothClassicMediumTest, CancelBluetoothPairing) {
|
||||
CountDownLatch found_latch(1);
|
||||
bt_a_->StartDiscovery(
|
||||
DiscoveryCallback{.device_discovered_cb = [&](BluetoothDevice& device) {
|
||||
NEARBY_LOGS(INFO) << "Device discovered: " << device.GetName();
|
||||
NEARBY_LOGS(INFO) << "Device discovered address: "
|
||||
LOG(INFO) << "Device discovered: " << device.GetName();
|
||||
LOG(INFO) << "Device discovered address: "
|
||||
<< device.GetMacAddress();
|
||||
EXPECT_EQ(device.GetName(), adapter_b_->GetName());
|
||||
discovered_device = &device;
|
||||
|
||||
@@ -37,17 +37,17 @@ TEST(ConditionVariableTest, CanWakeupWaiter) {
|
||||
ConditionVariable cond{&mutex};
|
||||
bool done = false;
|
||||
bool waiting = false;
|
||||
NEARBY_LOGS(INFO) << "At start; done=" << done;
|
||||
LOG(INFO) << "At start; done=" << done;
|
||||
{
|
||||
SingleThreadExecutor executor;
|
||||
executor.Execute([&cond, &mutex, &done, &waiting]() {
|
||||
MutexLock lock(&mutex);
|
||||
NEARBY_LOGS(INFO) << "Before cond.Wait(); done=" << done;
|
||||
LOG(INFO) << "Before cond.Wait(); done=" << done;
|
||||
waiting = true;
|
||||
cond.Wait();
|
||||
waiting = false;
|
||||
done = true;
|
||||
NEARBY_LOGS(INFO) << "After cond.Wait(); done=" << done;
|
||||
LOG(INFO) << "After cond.Wait(); done=" << done;
|
||||
});
|
||||
while (true) {
|
||||
{
|
||||
@@ -62,7 +62,7 @@ TEST(ConditionVariableTest, CanWakeupWaiter) {
|
||||
EXPECT_FALSE(done);
|
||||
}
|
||||
}
|
||||
NEARBY_LOGS(INFO) << "After executor shutdown: done=" << done;
|
||||
LOG(INFO) << "After executor shutdown: done=" << done;
|
||||
EXPECT_TRUE(done);
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ void ErrorCodeRecorder::LogErrorCode(Medium medium, Event event, int error,
|
||||
Description description,
|
||||
const std::string& pii_message,
|
||||
const std::string& connection_token) {
|
||||
NEARBY_LOGS(INFO) << "ErrorCodeRecorder LogErrorCode";
|
||||
LOG(INFO) << "ErrorCodeRecorder LogErrorCode";
|
||||
ErrorCodeParams params = BuildErrorCodeParams(
|
||||
medium, event, error, description, pii_message, connection_token);
|
||||
listener_(params);
|
||||
|
||||
@@ -65,7 +65,7 @@ bool BleServerSocket::Connect(BleSocket& socket) {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
if (closed_) return false;
|
||||
if (socket.IsConnected()) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "Failed to connect to Ble server socket: already connected";
|
||||
return true; // already connected.
|
||||
}
|
||||
@@ -127,7 +127,7 @@ BleMedium::~BleMedium() {
|
||||
StopScanning(scanning_info_.service_id);
|
||||
|
||||
accept_loops_runner_.Shutdown();
|
||||
NEARBY_LOGS(INFO) << "BleMedium dtor advertising_accept_thread_running_ = "
|
||||
LOG(INFO) << "BleMedium dtor advertising_accept_thread_running_ = "
|
||||
<< acceptance_thread_running_.load();
|
||||
// If acceptance thread is still running, wait to finish.
|
||||
if (acceptance_thread_running_) {
|
||||
@@ -142,7 +142,7 @@ BleMedium::~BleMedium() {
|
||||
bool BleMedium::StartAdvertising(
|
||||
const std::string& service_id, const ByteArray& advertisement_bytes,
|
||||
const std::string& fast_advertisement_service_uuid) {
|
||||
NEARBY_LOGS(INFO) << "G3 Ble StartAdvertising: service_id=" << service_id
|
||||
LOG(INFO) << "G3 Ble StartAdvertising: service_id=" << service_id
|
||||
<< ", advertisement bytes="
|
||||
<< absl::BytesToHexString(std::string(advertisement_bytes))
|
||||
<< "(" << advertisement_bytes.size() << "),"
|
||||
@@ -176,11 +176,11 @@ bool BleMedium::StartAdvertising(
|
||||
}
|
||||
|
||||
bool BleMedium::StopAdvertising(const std::string& service_id) {
|
||||
NEARBY_LOGS(INFO) << "G3 Ble StopAdvertising: service_id=" << service_id;
|
||||
LOG(INFO) << "G3 Ble StopAdvertising: service_id=" << service_id;
|
||||
{
|
||||
absl::MutexLock lock(&mutex_);
|
||||
if (advertising_info_.Empty()) {
|
||||
NEARBY_LOGS(INFO) << "G3 Ble StopAdvertising: Can't stop advertising "
|
||||
LOG(INFO) << "G3 Ble StopAdvertising: Can't stop advertising "
|
||||
"because we never started advertising.";
|
||||
return false;
|
||||
}
|
||||
@@ -193,7 +193,7 @@ bool BleMedium::StopAdvertising(const std::string& service_id) {
|
||||
/*enabled=*/false);
|
||||
accept_loops_runner_.Shutdown();
|
||||
if (server_socket_ == nullptr) {
|
||||
NEARBY_LOGS(ERROR) << "G3 Ble StopAdvertising: Failed to find Ble Server "
|
||||
LOG(ERROR) << "G3 Ble StopAdvertising: Failed to find Ble Server "
|
||||
"socket: service_id="
|
||||
<< service_id;
|
||||
// Fall through for server socket not found.
|
||||
@@ -201,7 +201,7 @@ bool BleMedium::StopAdvertising(const std::string& service_id) {
|
||||
}
|
||||
|
||||
if (!server_socket_->Close().Ok()) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "G3 Ble StopAdvertising: Failed to close Ble server socket for "
|
||||
<< service_id;
|
||||
return false;
|
||||
@@ -213,7 +213,7 @@ bool BleMedium::StartScanning(
|
||||
const std::string& service_id,
|
||||
const std::string& fast_advertisement_service_uuid,
|
||||
DiscoveredPeripheralCallback callback) {
|
||||
NEARBY_LOGS(INFO) << "G3 Ble StartScanning: service_id=" << service_id;
|
||||
LOG(INFO) << "G3 Ble StartScanning: service_id=" << service_id;
|
||||
auto& env = MediumEnvironment::Instance();
|
||||
env.UpdateBleMediumForScanning(*this, service_id,
|
||||
fast_advertisement_service_uuid,
|
||||
@@ -226,11 +226,11 @@ bool BleMedium::StartScanning(
|
||||
}
|
||||
|
||||
bool BleMedium::StopScanning(const std::string& service_id) {
|
||||
NEARBY_LOGS(INFO) << "G3 Ble StopScanning: service_id=" << service_id;
|
||||
LOG(INFO) << "G3 Ble StopScanning: service_id=" << service_id;
|
||||
{
|
||||
absl::MutexLock lock(&mutex_);
|
||||
if (scanning_info_.Empty()) {
|
||||
NEARBY_LOGS(INFO) << "G3 Ble StopDiscovery: Can't stop scanning because "
|
||||
LOG(INFO) << "G3 Ble StopDiscovery: Can't stop scanning because "
|
||||
"we never started scanning.";
|
||||
return false;
|
||||
}
|
||||
@@ -244,7 +244,7 @@ bool BleMedium::StopScanning(const std::string& service_id) {
|
||||
|
||||
bool BleMedium::StartAcceptingConnections(const std::string& service_id,
|
||||
AcceptedConnectionCallback callback) {
|
||||
NEARBY_LOGS(INFO) << "G3 Ble StartAcceptingConnections: service_id="
|
||||
LOG(INFO) << "G3 Ble StartAcceptingConnections: service_id="
|
||||
<< service_id;
|
||||
auto& env = MediumEnvironment::Instance();
|
||||
env.UpdateBleMediumForAcceptedConnection(*this, service_id,
|
||||
@@ -253,7 +253,7 @@ bool BleMedium::StartAcceptingConnections(const std::string& service_id,
|
||||
}
|
||||
|
||||
bool BleMedium::StopAcceptingConnections(const std::string& service_id) {
|
||||
NEARBY_LOGS(INFO) << "G3 Ble StopAcceptingConnections: service_id="
|
||||
LOG(INFO) << "G3 Ble StopAcceptingConnections: service_id="
|
||||
<< service_id;
|
||||
auto& env = MediumEnvironment::Instance();
|
||||
env.UpdateBleMediumForAcceptedConnection(*this, service_id, {});
|
||||
@@ -263,7 +263,7 @@ bool BleMedium::StopAcceptingConnections(const std::string& service_id) {
|
||||
std::unique_ptr<api::BleSocket> BleMedium::Connect(
|
||||
api::BlePeripheral& remote_peripheral, const std::string& service_id,
|
||||
CancellationFlag* cancellation_flag) {
|
||||
NEARBY_LOGS(INFO) << "G3 Ble Connect [self]: medium=" << this
|
||||
LOG(INFO) << "G3 Ble Connect [self]: medium=" << this
|
||||
<< ", adapter=" << &GetAdapter()
|
||||
<< ", peripheral=" << &GetAdapter().GetPeripheral()
|
||||
<< ", service_id=" << service_id;
|
||||
@@ -274,7 +274,7 @@ std::unique_ptr<api::BleSocket> BleMedium::Connect(
|
||||
if (!medium) return {}; // Can't find medium. Bail out.
|
||||
|
||||
BleServerSocket* remote_server_socket = nullptr;
|
||||
NEARBY_LOGS(INFO) << "G3 Ble Connect [peer]: medium=" << medium
|
||||
LOG(INFO) << "G3 Ble Connect [peer]: medium=" << medium
|
||||
<< ", adapter=" << &adapter
|
||||
<< ", peripheral=" << &remote_peripheral
|
||||
<< ", service_id=" << service_id;
|
||||
@@ -283,7 +283,7 @@ std::unique_ptr<api::BleSocket> BleMedium::Connect(
|
||||
absl::MutexLock medium_lock(&medium->mutex_);
|
||||
remote_server_socket = medium->server_socket_.get();
|
||||
if (remote_server_socket == nullptr) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "G3 Ble Connect: Failed to find Ble Server socket: service_id="
|
||||
<< service_id;
|
||||
return {};
|
||||
@@ -291,14 +291,14 @@ std::unique_ptr<api::BleSocket> BleMedium::Connect(
|
||||
}
|
||||
|
||||
if (cancellation_flag->Cancelled()) {
|
||||
NEARBY_LOGS(ERROR) << "G3 BLE Connect: Has been cancelled: "
|
||||
LOG(ERROR) << "G3 BLE Connect: Has been cancelled: "
|
||||
"service_id="
|
||||
<< service_id;
|
||||
return {};
|
||||
}
|
||||
|
||||
CancellationFlagListener listener(cancellation_flag, [this]() {
|
||||
NEARBY_LOGS(INFO) << "G3 BLE Cancel Connect.";
|
||||
LOG(INFO) << "G3 BLE Cancel Connect.";
|
||||
if (server_socket_ != nullptr) server_socket_->Close();
|
||||
});
|
||||
|
||||
@@ -306,13 +306,13 @@ std::unique_ptr<api::BleSocket> BleMedium::Connect(
|
||||
auto socket = std::make_unique<BleSocket>(&peripheral);
|
||||
// Finally, Request to connect to this socket.
|
||||
if (!remote_server_socket->Connect(*socket)) {
|
||||
NEARBY_LOGS(ERROR) << "G3 Ble Connect: Failed to connect to existing Ble "
|
||||
LOG(ERROR) << "G3 Ble Connect: Failed to connect to existing Ble "
|
||||
"Server socket: service_id="
|
||||
<< service_id;
|
||||
return {};
|
||||
}
|
||||
|
||||
NEARBY_LOGS(INFO) << "G3 Ble Connect: connected: socket=" << socket.get();
|
||||
LOG(INFO) << "G3 Ble Connect: connected: socket=" << socket.get();
|
||||
return socket;
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ bool BluetoothServerSocket::Connect(BluetoothSocket& socket) {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
if (closed_) return false;
|
||||
if (socket.IsConnected()) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "Failed to connect to BT server socket: already connected";
|
||||
return true; // already connected.
|
||||
}
|
||||
@@ -171,7 +171,7 @@ bool BluetoothClassicMedium::StopDiscovery() {
|
||||
std::unique_ptr<api::BluetoothSocket> BluetoothClassicMedium::ConnectToService(
|
||||
api::BluetoothDevice& remote_device, const std::string& service_uuid,
|
||||
CancellationFlag* cancellation_flag) {
|
||||
NEARBY_LOGS(INFO) << "G3 ConnectToService [self]: medium=" << this
|
||||
LOG(INFO) << "G3 ConnectToService [self]: medium=" << this
|
||||
<< ", adapter=" << &GetAdapter()
|
||||
<< ", device=" << &GetAdapter().GetDevice();
|
||||
// First, find an instance of remote medium, that exposed this device.
|
||||
@@ -182,7 +182,7 @@ std::unique_ptr<api::BluetoothSocket> BluetoothClassicMedium::ConnectToService(
|
||||
if (!medium) return {}; // Adapter is not bound to medium. Bail out.
|
||||
|
||||
BluetoothServerSocket* server_socket = nullptr;
|
||||
NEARBY_LOGS(INFO) << "G3 ConnectToService [peer]: medium=" << medium
|
||||
LOG(INFO) << "G3 ConnectToService [peer]: medium=" << medium
|
||||
<< ", adapter=" << &adapter << ", device=" << &remote_device
|
||||
<< ", uuid=" << service_uuid.c_str();
|
||||
// Then, find our server socket context in this medium.
|
||||
@@ -191,35 +191,35 @@ std::unique_ptr<api::BluetoothSocket> BluetoothClassicMedium::ConnectToService(
|
||||
auto item = medium->sockets_.find(service_uuid);
|
||||
server_socket = item != medium->sockets_.end() ? item->second : nullptr;
|
||||
if (server_socket == nullptr) {
|
||||
NEARBY_LOGS(ERROR) << "Failed to find BT Server socket: uuid="
|
||||
LOG(ERROR) << "Failed to find BT Server socket: uuid="
|
||||
<< service_uuid;
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
if (cancellation_flag->Cancelled()) {
|
||||
NEARBY_LOGS(ERROR) << "G3 Bluetooth Connect: Has been cancelled: "
|
||||
LOG(ERROR) << "G3 Bluetooth Connect: Has been cancelled: "
|
||||
"service_uuid="
|
||||
<< service_uuid;
|
||||
return {};
|
||||
}
|
||||
|
||||
CancellationFlagListener listener(cancellation_flag, [&server_socket]() {
|
||||
NEARBY_LOGS(INFO) << "G3 Bluetooth Cancel Connect.";
|
||||
LOG(INFO) << "G3 Bluetooth Cancel Connect.";
|
||||
if (server_socket != nullptr) server_socket->Close();
|
||||
});
|
||||
|
||||
auto socket = std::make_unique<BluetoothSocket>(&GetAdapter());
|
||||
// Finally, Request to connect to this socket.
|
||||
if (!server_socket->Connect(*socket)) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "Failed to connect to existing BT Server socket: uuid="
|
||||
<< service_uuid;
|
||||
return {};
|
||||
}
|
||||
|
||||
if (cancellation_flag->Cancelled()) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "G3 Bluetooth Connect: Has been cancelled after connected: "
|
||||
"service_uuid="
|
||||
<< service_uuid;
|
||||
@@ -227,7 +227,7 @@ std::unique_ptr<api::BluetoothSocket> BluetoothClassicMedium::ConnectToService(
|
||||
return {};
|
||||
}
|
||||
|
||||
NEARBY_LOGS(INFO) << "G3 ConnectToService: connected: socket="
|
||||
LOG(INFO) << "G3 ConnectToService: connected: socket="
|
||||
<< socket.get();
|
||||
return socket;
|
||||
}
|
||||
@@ -240,7 +240,7 @@ BluetoothClassicMedium::ListenForService(const std::string& service_name,
|
||||
absl::MutexLock lock(&mutex_);
|
||||
sockets_.erase(uuid);
|
||||
});
|
||||
NEARBY_LOGS(INFO) << "Adding service: medium=" << this
|
||||
LOG(INFO) << "Adding service: medium=" << this
|
||||
<< ", uuid=" << service_uuid;
|
||||
absl::MutexLock lock(&mutex_);
|
||||
sockets_.emplace(service_uuid, socket.get());
|
||||
|
||||
@@ -63,11 +63,11 @@ void CredentialStorageImpl::SaveCredentials(
|
||||
return;
|
||||
}
|
||||
if (private_credentials.empty()) {
|
||||
NEARBY_LOGS(INFO) << "There are no Private Credentials for account: ["
|
||||
LOG(INFO) << "There are no Private Credentials for account: ["
|
||||
<< account_name << "], manager app ID:[" << manager_app_id
|
||||
<< "]";
|
||||
} else {
|
||||
NEARBY_LOGS(INFO) << "G3 Save Private Credentials for account: ["
|
||||
LOG(INFO) << "G3 Save Private Credentials for account: ["
|
||||
<< account_name << "], manager app ID:[" << manager_app_id
|
||||
<< "]";
|
||||
SaveLocalCredentialsLocked(manager_app_id, account_name,
|
||||
@@ -75,11 +75,11 @@ void CredentialStorageImpl::SaveCredentials(
|
||||
}
|
||||
|
||||
if (public_credentials.empty()) {
|
||||
NEARBY_LOGS(INFO) << "There are no Public Credentials for account: ["
|
||||
LOG(INFO) << "There are no Public Credentials for account: ["
|
||||
<< account_name << "], manager app ID:[" << manager_app_id
|
||||
<< "]";
|
||||
} else {
|
||||
NEARBY_LOGS(INFO) << "G3 Save Public Credentials for account: ["
|
||||
LOG(INFO) << "G3 Save Public Credentials for account: ["
|
||||
<< account_name << "], manager app ID:[" << manager_app_id
|
||||
<< "]";
|
||||
PublicCredentialKey key = CreatePublicCredentialKey(
|
||||
@@ -87,7 +87,7 @@ void CredentialStorageImpl::SaveCredentials(
|
||||
auto public_result =
|
||||
public_credentials_map_.insert(std::make_pair(key, public_credentials));
|
||||
if (!public_result.second) {
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< "Credentials already saved in map. Overwriting previous creds!";
|
||||
public_credentials_map_[key] = public_credentials;
|
||||
}
|
||||
@@ -102,7 +102,7 @@ void CredentialStorageImpl::SaveLocalCredentialsLocked(
|
||||
auto private_result =
|
||||
private_credentials_map_.insert(std::make_pair(key, private_credentials));
|
||||
if (!private_result.second) {
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< "Credentials already saved in map. Overwriting previous creds!";
|
||||
private_credentials_map_[key] = private_credentials;
|
||||
}
|
||||
@@ -111,7 +111,7 @@ void CredentialStorageImpl::SaveLocalCredentialsLocked(
|
||||
void CredentialStorageImpl::UpdateLocalCredential(
|
||||
absl::string_view manager_app_id, absl::string_view account_name,
|
||||
LocalCredential credential, SaveCredentialsResultCallback callback) {
|
||||
NEARBY_LOGS(INFO) << "G3 Update Private Credential for for account: ["
|
||||
LOG(INFO) << "G3 Update Private Credential for for account: ["
|
||||
<< account_name << "], manager app ID:[" << manager_app_id
|
||||
<< "]";
|
||||
absl::StatusOr<std::vector<LocalCredential>> credentials =
|
||||
@@ -120,7 +120,7 @@ void CredentialStorageImpl::UpdateLocalCredential(
|
||||
.account_name = std::string(account_name),
|
||||
.identity_type = IdentityType::IDENTITY_TYPE_UNSPECIFIED});
|
||||
if (!credentials.ok()) {
|
||||
NEARBY_LOGS(WARNING) << credentials.status();
|
||||
LOG(WARNING) << credentials.status();
|
||||
credentials = std::vector<LocalCredential>();
|
||||
}
|
||||
auto it = std::find_if(
|
||||
@@ -138,7 +138,7 @@ void CredentialStorageImpl::UpdateLocalCredential(
|
||||
void CredentialStorageImpl::GetLocalCredentials(
|
||||
const CredentialSelector& credential_selector,
|
||||
GetLocalCredentialsResultCallback callback) {
|
||||
NEARBY_LOGS(INFO) << "G3 Get Private Credentials for " << credential_selector;
|
||||
LOG(INFO) << "G3 Get Private Credentials for " << credential_selector;
|
||||
std::move(callback.credentials_fetched_cb)(
|
||||
GetLocalCredentialsLocked(credential_selector));
|
||||
}
|
||||
@@ -149,7 +149,7 @@ CredentialStorageImpl::GetLocalCredentialsLocked(
|
||||
LocalCredentialKey key = CreateLocalCredentialKey(
|
||||
credential_selector.manager_app_id, credential_selector.account_name);
|
||||
if (private_credentials_map_.find(key) == private_credentials_map_.end()) {
|
||||
NEARBY_LOGS(WARNING) << "There are no Private Credentials stored for key:"
|
||||
LOG(WARNING) << "There are no Private Credentials stored for key:"
|
||||
<< std::get<0>(key) << ", " << std::get<1>(key);
|
||||
return absl::NotFoundError(
|
||||
absl::StrFormat("No private credentials for %v", credential_selector));
|
||||
@@ -168,12 +168,12 @@ void CredentialStorageImpl::GetPublicCredentials(
|
||||
const CredentialSelector& credential_selector,
|
||||
PublicCredentialType public_credential_type,
|
||||
GetPublicCredentialsResultCallback callback) {
|
||||
NEARBY_LOGS(INFO) << "G3 Get Public Credentials for " << credential_selector;
|
||||
LOG(INFO) << "G3 Get Public Credentials for " << credential_selector;
|
||||
PublicCredentialKey key = CreatePublicCredentialKey(
|
||||
credential_selector.manager_app_id, credential_selector.account_name,
|
||||
public_credential_type);
|
||||
if (public_credentials_map_.find(key) == public_credentials_map_.end()) {
|
||||
NEARBY_LOGS(WARNING) << "There are no Public Credentials stored for key:"
|
||||
LOG(WARNING) << "There are no Public Credentials stored for key:"
|
||||
<< std::get<0>(key) << ", " << std::get<1>(key) << ", "
|
||||
<< std::get<2>(key);
|
||||
std::move(callback.credentials_fetched_cb)(absl::NotFoundError(
|
||||
|
||||
@@ -183,7 +183,7 @@ void PreferencesManager::Remove(absl::string_view key) {
|
||||
// Writes data to storage.
|
||||
bool PreferencesManager::Commit() {
|
||||
if (!preferences_repository_->SavePreferences(value_)) {
|
||||
NEARBY_LOGS(ERROR) << "Failed to save preference." << std::endl;
|
||||
LOG(ERROR) << "Failed to save preference." << std::endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -63,7 +63,7 @@ bool WifiDirectServerSocket::Connect(WifiDirectSocket& socket) {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
if (closed_) return false;
|
||||
if (socket.IsConnected()) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "Failed to connect to WifiDirect server socket: already connected";
|
||||
return true; // already connected.
|
||||
}
|
||||
@@ -130,7 +130,7 @@ bool WifiDirectMedium::StartWifiDirect(
|
||||
std::string password = absl::StrFormat("%08x", Prng().NextUint32());
|
||||
wifi_direct_credentials->SetPassword(password);
|
||||
|
||||
NEARBY_LOGS(INFO) << "G3 StartWifiDirect GO: ssid=" << ssid
|
||||
LOG(INFO) << "G3 StartWifiDirect GO: ssid=" << ssid
|
||||
<< ", password:" << password;
|
||||
|
||||
auto& env = MediumEnvironment::Instance();
|
||||
@@ -142,7 +142,7 @@ bool WifiDirectMedium::StartWifiDirect(
|
||||
|
||||
bool WifiDirectMedium::StopWifiDirect() {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
NEARBY_LOGS(INFO) << "G3 StopWifiDirect GO";
|
||||
LOG(INFO) << "G3 StopWifiDirect GO";
|
||||
|
||||
auto& env = MediumEnvironment::Instance();
|
||||
env.UpdateWifiDirectMediumForStartOrConnect(*this, /*credentials*/ nullptr,
|
||||
@@ -155,7 +155,7 @@ bool WifiDirectMedium::ConnectWifiDirect(
|
||||
WifiDirectCredentials* wifi_direct_credentials) {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
|
||||
NEARBY_LOGS(INFO) << "G3 ConnectWifiDirect : ssid="
|
||||
LOG(INFO) << "G3 ConnectWifiDirect : ssid="
|
||||
<< wifi_direct_credentials->GetSSID()
|
||||
<< ", password:" << wifi_direct_credentials->GetPassword();
|
||||
|
||||
@@ -178,7 +178,7 @@ bool WifiDirectMedium::ConnectWifiDirect(
|
||||
bool WifiDirectMedium::DisconnectWifiDirect() {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
|
||||
NEARBY_LOGS(INFO) << "G3 DisconnectWifiDirect";
|
||||
LOG(INFO) << "G3 DisconnectWifiDirect";
|
||||
|
||||
auto& env = MediumEnvironment::Instance();
|
||||
env.UpdateWifiDirectMediumForStartOrConnect(*this, /*credentials*/ nullptr,
|
||||
@@ -191,7 +191,7 @@ std::unique_ptr<api::WifiDirectSocket> WifiDirectMedium::ConnectToService(
|
||||
absl::string_view ip_address, int port,
|
||||
CancellationFlag* cancellation_flag) {
|
||||
std::string socket_name = WifiDirectServerSocket::GetName(ip_address, port);
|
||||
NEARBY_LOGS(INFO) << "G3 WifiDirect ConnectToService [self]: medium=" << this
|
||||
LOG(INFO) << "G3 WifiDirect ConnectToService [self]: medium=" << this
|
||||
<< ", ip address + port=" << socket_name;
|
||||
// First, find an instance of remote medium, that exposed this service.
|
||||
auto& env = MediumEnvironment::Instance();
|
||||
@@ -202,7 +202,7 @@ std::unique_ptr<api::WifiDirectSocket> WifiDirectMedium::ConnectToService(
|
||||
}
|
||||
|
||||
WifiDirectServerSocket* server_socket = nullptr;
|
||||
NEARBY_LOGS(INFO) << "G3 WifiDirect ConnectToService [peer]: medium="
|
||||
LOG(INFO) << "G3 WifiDirect ConnectToService [peer]: medium="
|
||||
<< remote_medium
|
||||
<< ", remote ip address + port=" << socket_name;
|
||||
// Then, find our server socket context in this medium.
|
||||
@@ -212,7 +212,7 @@ std::unique_ptr<api::WifiDirectSocket> WifiDirectMedium::ConnectToService(
|
||||
server_socket =
|
||||
item != remote_medium->server_sockets_.end() ? item->second : nullptr;
|
||||
if (server_socket == nullptr) {
|
||||
NEARBY_LOGS(ERROR) << "G3 WifiDirect Failed to find WifiDirect Server "
|
||||
LOG(ERROR) << "G3 WifiDirect Failed to find WifiDirect Server "
|
||||
"socket: socket_name="
|
||||
<< socket_name;
|
||||
return nullptr;
|
||||
@@ -220,7 +220,7 @@ std::unique_ptr<api::WifiDirectSocket> WifiDirectMedium::ConnectToService(
|
||||
}
|
||||
|
||||
if (cancellation_flag->Cancelled()) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "G3 WifiDirect Connect: Has been cancelled: socket_name="
|
||||
<< socket_name;
|
||||
return nullptr;
|
||||
@@ -230,7 +230,7 @@ std::unique_ptr<api::WifiDirectSocket> WifiDirectMedium::ConnectToService(
|
||||
// Finally, Request to connect to this socket.
|
||||
|
||||
server_socket->Connect(*socket);
|
||||
NEARBY_LOGS(INFO) << "G3 WifiDirect GC ConnectToService: connected: socket="
|
||||
LOG(INFO) << "G3 WifiDirect GC ConnectToService: connected: socket="
|
||||
<< socket.get();
|
||||
return socket;
|
||||
}
|
||||
@@ -256,7 +256,7 @@ std::unique_ptr<api::WifiDirectServerSocket> WifiDirectMedium::ListenForService(
|
||||
absl::MutexLock lock(&mutex_);
|
||||
server_sockets_.erase(socket_name);
|
||||
});
|
||||
NEARBY_LOGS(INFO) << "G3 WifiDirect GO Adding server socket: medium=" << this
|
||||
LOG(INFO) << "G3 WifiDirect GO Adding server socket: medium=" << this
|
||||
<< ", socket_name=" << socket_name;
|
||||
absl::MutexLock lock(&mutex_);
|
||||
server_sockets_.insert({socket_name, server_socket.get()});
|
||||
|
||||
@@ -64,7 +64,7 @@ bool WifiHotspotServerSocket::Connect(WifiHotspotSocket& socket) {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
if (closed_) return false;
|
||||
if (socket.IsConnected()) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "Failed to connect to WifiHotspot server socket: already connected";
|
||||
return true; // already connected.
|
||||
}
|
||||
@@ -133,7 +133,7 @@ bool WifiHotspotMedium::StartWifiHotspot(
|
||||
std::string password = absl::StrFormat("%08x", Prng().NextUint32());
|
||||
hotspot_credentials->SetPassword(password);
|
||||
|
||||
NEARBY_LOGS(INFO) << "G3 StartWifiHotspot: ssid=" << ssid
|
||||
LOG(INFO) << "G3 StartWifiHotspot: ssid=" << ssid
|
||||
<< ", password:" << password;
|
||||
|
||||
auto& env = MediumEnvironment::Instance();
|
||||
@@ -146,7 +146,7 @@ bool WifiHotspotMedium::StartWifiHotspot(
|
||||
|
||||
bool WifiHotspotMedium::StopWifiHotspot() {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
NEARBY_LOGS(INFO) << "G3 StopWifiHotspot";
|
||||
LOG(INFO) << "G3 StopWifiHotspot";
|
||||
|
||||
if (!IsInterfaceValid()) return false;
|
||||
|
||||
@@ -161,7 +161,7 @@ bool WifiHotspotMedium::ConnectWifiHotspot(
|
||||
HotspotCredentials* hotspot_credentials) {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
|
||||
NEARBY_LOGS(INFO) << "G3 ConnectWifiHotspot: ssid="
|
||||
LOG(INFO) << "G3 ConnectWifiHotspot: ssid="
|
||||
<< hotspot_credentials->GetSSID()
|
||||
<< ", password:" << hotspot_credentials->GetPassword();
|
||||
|
||||
@@ -184,7 +184,7 @@ bool WifiHotspotMedium::ConnectWifiHotspot(
|
||||
bool WifiHotspotMedium::DisconnectWifiHotspot() {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
|
||||
NEARBY_LOGS(INFO) << "G3 DisconnectWifiHotspot";
|
||||
LOG(INFO) << "G3 DisconnectWifiHotspot";
|
||||
|
||||
auto& env = MediumEnvironment::Instance();
|
||||
env.UpdateWifiHotspotMediumForStartOrConnect(*this, /*credentials*/ nullptr,
|
||||
@@ -197,7 +197,7 @@ std::unique_ptr<api::WifiHotspotSocket> WifiHotspotMedium::ConnectToService(
|
||||
absl::string_view ip_address, int port,
|
||||
CancellationFlag* cancellation_flag) {
|
||||
std::string socket_name = WifiHotspotServerSocket::GetName(ip_address, port);
|
||||
NEARBY_LOGS(INFO) << "G3 WifiHotspot ConnectToService [self]: medium=" << this
|
||||
LOG(INFO) << "G3 WifiHotspot ConnectToService [self]: medium=" << this
|
||||
<< ", ip address + port=" << socket_name;
|
||||
// First, find an instance of remote medium, that exposed this service.
|
||||
auto& env = MediumEnvironment::Instance();
|
||||
@@ -208,7 +208,7 @@ std::unique_ptr<api::WifiHotspotSocket> WifiHotspotMedium::ConnectToService(
|
||||
}
|
||||
|
||||
WifiHotspotServerSocket* server_socket = nullptr;
|
||||
NEARBY_LOGS(INFO) << "G3 WifiHotspot ConnectToService [peer]: medium="
|
||||
LOG(INFO) << "G3 WifiHotspot ConnectToService [peer]: medium="
|
||||
<< remote_medium
|
||||
<< ", remote ip address + port=" << socket_name;
|
||||
// Then, find our server socket context in this medium.
|
||||
@@ -218,7 +218,7 @@ std::unique_ptr<api::WifiHotspotSocket> WifiHotspotMedium::ConnectToService(
|
||||
server_socket =
|
||||
item != remote_medium->server_sockets_.end() ? item->second : nullptr;
|
||||
if (server_socket == nullptr) {
|
||||
NEARBY_LOGS(ERROR) << "G3 WifiHotspot Failed to find WifiHotspot Server "
|
||||
LOG(ERROR) << "G3 WifiHotspot Failed to find WifiHotspot Server "
|
||||
"socket: socket_name="
|
||||
<< socket_name;
|
||||
return {};
|
||||
@@ -226,14 +226,14 @@ std::unique_ptr<api::WifiHotspotSocket> WifiHotspotMedium::ConnectToService(
|
||||
}
|
||||
|
||||
if (cancellation_flag->Cancelled()) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "G3 WifiHotspot Connect: Has been cancelled: socket_name="
|
||||
<< socket_name;
|
||||
return {};
|
||||
}
|
||||
|
||||
CancellationFlagListener listener(cancellation_flag, [&server_socket]() {
|
||||
NEARBY_LOGS(INFO) << "G3 WifiHotspot Cancel Connect.";
|
||||
LOG(INFO) << "G3 WifiHotspot Cancel Connect.";
|
||||
if (server_socket != nullptr) {
|
||||
server_socket->Close();
|
||||
}
|
||||
@@ -242,13 +242,13 @@ std::unique_ptr<api::WifiHotspotSocket> WifiHotspotMedium::ConnectToService(
|
||||
auto socket = std::make_unique<WifiHotspotSocket>();
|
||||
// Finally, Request to connect to this socket.
|
||||
if (!server_socket->Connect(*socket)) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "G3 WifiHotspot Failed to connect to existing WifiHotspot "
|
||||
"Server socket: name="
|
||||
<< socket_name;
|
||||
return {};
|
||||
}
|
||||
NEARBY_LOGS(INFO) << "G3 WifiHotspot ConnectToService: connected: socket="
|
||||
LOG(INFO) << "G3 WifiHotspot ConnectToService: connected: socket="
|
||||
<< socket.get();
|
||||
return socket;
|
||||
}
|
||||
@@ -275,7 +275,7 @@ WifiHotspotMedium::ListenForService(int port) {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
server_sockets_.erase(socket_name);
|
||||
});
|
||||
NEARBY_LOGS(INFO) << "G3 WifiHotspot Adding server socket: medium=" << this
|
||||
LOG(INFO) << "G3 WifiHotspot Adding server socket: medium=" << this
|
||||
<< ", socket_name=" << socket_name;
|
||||
absl::MutexLock lock(&mutex_);
|
||||
server_sockets_.insert({socket_name, server_socket.get()});
|
||||
|
||||
@@ -70,7 +70,7 @@ bool WifiLanServerSocket::Connect(WifiLanSocket& socket) {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
if (closed_) return false;
|
||||
if (socket.IsConnected()) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "Failed to connect to WifiLan server socket: already connected";
|
||||
return true; // already connected.
|
||||
}
|
||||
@@ -129,14 +129,14 @@ WifiLanMedium::~WifiLanMedium() {
|
||||
|
||||
bool WifiLanMedium::StartAdvertising(const NsdServiceInfo& nsd_service_info) {
|
||||
std::string service_type = nsd_service_info.GetServiceType();
|
||||
NEARBY_LOGS(INFO) << "G3 WifiLan StartAdvertising: nsd_service_info="
|
||||
LOG(INFO) << "G3 WifiLan StartAdvertising: nsd_service_info="
|
||||
<< &nsd_service_info
|
||||
<< ", service_name=" << nsd_service_info.GetServiceName()
|
||||
<< ", service_type=" << service_type;
|
||||
{
|
||||
absl::MutexLock lock(&mutex_);
|
||||
if (advertising_info_.Existed(service_type)) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "G3 WifiLan StartAdvertising: Can't start advertising because "
|
||||
"service_type="
|
||||
<< service_type << ", has started already.";
|
||||
@@ -155,14 +155,14 @@ bool WifiLanMedium::StartAdvertising(const NsdServiceInfo& nsd_service_info) {
|
||||
|
||||
bool WifiLanMedium::StopAdvertising(const NsdServiceInfo& nsd_service_info) {
|
||||
std::string service_type = nsd_service_info.GetServiceType();
|
||||
NEARBY_LOGS(INFO) << "G3 WifiLan StopAdvertising: nsd_service_info="
|
||||
LOG(INFO) << "G3 WifiLan StopAdvertising: nsd_service_info="
|
||||
<< &nsd_service_info
|
||||
<< ", service_name=" << nsd_service_info.GetServiceName()
|
||||
<< ", service_type=" << service_type;
|
||||
{
|
||||
absl::MutexLock lock(&mutex_);
|
||||
if (!advertising_info_.Existed(service_type)) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "G3 WifiLan StopAdvertising: Can't stop advertising because "
|
||||
"we never started advertising for service_type="
|
||||
<< service_type;
|
||||
@@ -178,12 +178,12 @@ bool WifiLanMedium::StopAdvertising(const NsdServiceInfo& nsd_service_info) {
|
||||
|
||||
bool WifiLanMedium::StartDiscovery(const std::string& service_type,
|
||||
DiscoveredServiceCallback callback) {
|
||||
NEARBY_LOGS(INFO) << "G3 WifiLan StartDiscovery: service_type="
|
||||
LOG(INFO) << "G3 WifiLan StartDiscovery: service_type="
|
||||
<< service_type;
|
||||
{
|
||||
absl::MutexLock lock(&mutex_);
|
||||
if (discovering_info_.Existed(service_type)) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "G3 WifiLan StartDiscovery: Can't start discovery because "
|
||||
"service_type="
|
||||
<< service_type << " has started already.";
|
||||
@@ -201,12 +201,12 @@ bool WifiLanMedium::StartDiscovery(const std::string& service_type,
|
||||
}
|
||||
|
||||
bool WifiLanMedium::StopDiscovery(const std::string& service_type) {
|
||||
NEARBY_LOGS(INFO) << "G3 WifiLan StopDiscovery: service_type="
|
||||
LOG(INFO) << "G3 WifiLan StopDiscovery: service_type="
|
||||
<< service_type;
|
||||
{
|
||||
absl::MutexLock lock(&mutex_);
|
||||
if (!discovering_info_.Existed(service_type)) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "G3 WifiLan StopDiscovery: Can't stop discovering because we "
|
||||
"never started discovering.";
|
||||
return false;
|
||||
@@ -222,7 +222,7 @@ std::unique_ptr<api::WifiLanSocket> WifiLanMedium::ConnectToService(
|
||||
const NsdServiceInfo& remote_service_info,
|
||||
CancellationFlag* cancellation_flag) {
|
||||
std::string service_type = remote_service_info.GetServiceType();
|
||||
NEARBY_LOGS(INFO) << "G3 WifiLan ConnectToService [self]: medium=" << this
|
||||
LOG(INFO) << "G3 WifiLan ConnectToService [self]: medium=" << this
|
||||
<< ", service_type=" << service_type;
|
||||
return ConnectToService(remote_service_info.GetIPAddress(),
|
||||
remote_service_info.GetPort(), cancellation_flag);
|
||||
@@ -232,7 +232,7 @@ std::unique_ptr<api::WifiLanSocket> WifiLanMedium::ConnectToService(
|
||||
const std::string& ip_address, int port,
|
||||
CancellationFlag* cancellation_flag) {
|
||||
std::string socket_name = WifiLanServerSocket::GetName(ip_address, port);
|
||||
NEARBY_LOGS(INFO) << "G3 WifiLan ConnectToService [self]: medium=" << this
|
||||
LOG(INFO) << "G3 WifiLan ConnectToService [self]: medium=" << this
|
||||
<< ", ip address + port=" << socket_name;
|
||||
// First, find an instance of remote medium, that exposed this service.
|
||||
auto& env = MediumEnvironment::Instance();
|
||||
@@ -243,7 +243,7 @@ std::unique_ptr<api::WifiLanSocket> WifiLanMedium::ConnectToService(
|
||||
}
|
||||
|
||||
WifiLanServerSocket* server_socket = nullptr;
|
||||
NEARBY_LOGS(INFO) << "G3 WifiLan ConnectToService [peer]: medium="
|
||||
LOG(INFO) << "G3 WifiLan ConnectToService [peer]: medium="
|
||||
<< remote_medium
|
||||
<< ", remote ip address + port=" << socket_name;
|
||||
// Then, find our server socket context in this medium.
|
||||
@@ -253,7 +253,7 @@ std::unique_ptr<api::WifiLanSocket> WifiLanMedium::ConnectToService(
|
||||
server_socket =
|
||||
item != remote_medium->server_sockets_.end() ? item->second : nullptr;
|
||||
if (server_socket == nullptr) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "G3 WifiLan Failed to find WifiLan Server socket: socket_name="
|
||||
<< socket_name;
|
||||
return {};
|
||||
@@ -261,13 +261,13 @@ std::unique_ptr<api::WifiLanSocket> WifiLanMedium::ConnectToService(
|
||||
}
|
||||
|
||||
if (cancellation_flag->Cancelled()) {
|
||||
NEARBY_LOGS(ERROR) << "G3 WifiLan Connect: Has been cancelled: socket_name="
|
||||
LOG(ERROR) << "G3 WifiLan Connect: Has been cancelled: socket_name="
|
||||
<< socket_name;
|
||||
return {};
|
||||
}
|
||||
|
||||
CancellationFlagListener listener(cancellation_flag, [&server_socket]() {
|
||||
NEARBY_LOGS(INFO) << "G3 WifiLan Cancel Connect.";
|
||||
LOG(INFO) << "G3 WifiLan Cancel Connect.";
|
||||
if (server_socket != nullptr) {
|
||||
server_socket->Close();
|
||||
}
|
||||
@@ -276,12 +276,12 @@ std::unique_ptr<api::WifiLanSocket> WifiLanMedium::ConnectToService(
|
||||
auto socket = std::make_unique<WifiLanSocket>();
|
||||
// Finally, Request to connect to this socket.
|
||||
if (!server_socket->Connect(*socket)) {
|
||||
NEARBY_LOGS(ERROR) << "G3 WifiLan Failed to connect to existing WifiLan "
|
||||
LOG(ERROR) << "G3 WifiLan Failed to connect to existing WifiLan "
|
||||
"Server socket: name="
|
||||
<< socket_name;
|
||||
return {};
|
||||
}
|
||||
NEARBY_LOGS(INFO) << "G3 WifiLan ConnectToService: connected: socket="
|
||||
LOG(INFO) << "G3 WifiLan ConnectToService: connected: socket="
|
||||
<< socket.get();
|
||||
return socket;
|
||||
}
|
||||
@@ -298,7 +298,7 @@ std::unique_ptr<api::WifiLanServerSocket> WifiLanMedium::ListenForService(
|
||||
absl::MutexLock lock(&mutex_);
|
||||
server_sockets_.erase(socket_name);
|
||||
});
|
||||
NEARBY_LOGS(INFO) << "G3 WifiLan Adding server socket: medium=" << this
|
||||
LOG(INFO) << "G3 WifiLan Adding server socket: medium=" << this
|
||||
<< ", socket_name=" << socket_name;
|
||||
absl::MutexLock lock(&mutex_);
|
||||
server_sockets_.insert({socket_name, server_socket.get()});
|
||||
|
||||
@@ -122,7 +122,7 @@ bool WifiLanMdns::StartMdnsService(
|
||||
DWORD status = DnsServiceRegister(&dns_service_register_request_, nullptr);
|
||||
|
||||
if (status != DNS_REQUEST_PENDING) {
|
||||
NEARBY_LOGS(ERROR) << "Failed to start mDNS advertising for service type ="
|
||||
LOG(ERROR) << "Failed to start mDNS advertising for service type ="
|
||||
<< service_type;
|
||||
return false;
|
||||
}
|
||||
@@ -156,7 +156,7 @@ bool WifiLanMdns::StopMdnsService() {
|
||||
DWORD status = DnsServiceDeRegister(&dns_service_register_request_, nullptr);
|
||||
|
||||
if (status != DNS_REQUEST_PENDING) {
|
||||
NEARBY_LOGS(ERROR) << "Failed to stop mDNS advertising.";
|
||||
LOG(ERROR) << "Failed to stop mDNS advertising.";
|
||||
CleanUp();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -29,12 +29,4 @@
|
||||
// IWYU pragma: end_exports
|
||||
#endif // defined(NEARBY_CHROMIUM)
|
||||
|
||||
// Public APIs
|
||||
// The stream statement must come last, or it won't compile.
|
||||
#define NEARBY_VLOG(level) VLOG(level)
|
||||
#define NEARBY_LOGS(severity) LOG(severity)
|
||||
|
||||
#define NEARBY_DLOG(severity) DLOG(severity)
|
||||
#define NEARBY_DVLOG(severity) DVLOG(severity)
|
||||
|
||||
#endif // PLATFORM_BASE_LOGGING_H_
|
||||
|
||||
@@ -176,7 +176,7 @@ void MediumEnvironment::OnBluetoothDeviceStateChanged(
|
||||
// Store device name, and report it as discovered.
|
||||
info.devices.emplace(&device, name);
|
||||
if (enable_notifications_) {
|
||||
NEARBY_VLOG(1) << "Notify about new discovered device";
|
||||
VLOG(1) << "Notify about new discovered device";
|
||||
info.callback.device_discovered_cb(device);
|
||||
for (auto& observer : observers_.GetObservers()) {
|
||||
observer->DeviceAdded(device);
|
||||
@@ -199,7 +199,7 @@ void MediumEnvironment::OnBluetoothDeviceStateChanged(
|
||||
} else {
|
||||
// Device is in discovery mode, so we are reporting it anyway.
|
||||
if (enable_notifications_) {
|
||||
NEARBY_VLOG(1) << "Notify about existing discovered device";
|
||||
VLOG(1) << "Notify about existing discovered device";
|
||||
info.callback.device_discovered_cb(device);
|
||||
for (auto& observer : observers_.GetObservers()) {
|
||||
observer->DeviceAdded(device);
|
||||
@@ -211,7 +211,7 @@ void MediumEnvironment::OnBluetoothDeviceStateChanged(
|
||||
// Known device is turned off.
|
||||
// Erase it from the map, and report as lost.
|
||||
if (enable_notifications_) {
|
||||
NEARBY_VLOG(1) << "Notify about removed device";
|
||||
VLOG(1) << "Notify about removed device";
|
||||
info.callback.device_lost_cb(device);
|
||||
for (auto& observer : observers_.GetObservers()) {
|
||||
observer->DeviceRemoved(device);
|
||||
|
||||
@@ -67,14 +67,14 @@ void PendingJobRegistry::ListJobs() {
|
||||
for (auto& job : pending_jobs_) {
|
||||
auto age = current_time - job.second;
|
||||
if (age >= kReportPendingJobsOlderThan) {
|
||||
NEARBY_LOGS(INFO) << "Task \"" << job.first << "\" is waiting for "
|
||||
LOG(INFO) << "Task \"" << job.first << "\" is waiting for "
|
||||
<< absl::ToInt64Seconds(age) << " s";
|
||||
}
|
||||
}
|
||||
for (auto& job : running_jobs_) {
|
||||
auto age = current_time - job.second;
|
||||
if (age >= kReportRunningJobsOlderThan) {
|
||||
NEARBY_LOGS(INFO) << "Task \"" << job.first << "\" is running for "
|
||||
LOG(INFO) << "Task \"" << job.first << "\" is running for "
|
||||
<< absl::ToInt64Seconds(age) << " s";
|
||||
}
|
||||
}
|
||||
@@ -86,12 +86,12 @@ void PendingJobRegistry::ListAllJobs() {
|
||||
auto current_time = SystemClock::ElapsedRealtime();
|
||||
for (auto& job : pending_jobs_) {
|
||||
auto age = current_time - job.second;
|
||||
NEARBY_LOGS(INFO) << "Task \"" << job.first << "\" is waiting for "
|
||||
LOG(INFO) << "Task \"" << job.first << "\" is waiting for "
|
||||
<< absl::ToInt64Seconds(age) << " s";
|
||||
}
|
||||
for (auto& job : running_jobs_) {
|
||||
auto age = current_time - job.second;
|
||||
NEARBY_LOGS(INFO) << "Task \"" << job.first << "\" is running for "
|
||||
LOG(INFO) << "Task \"" << job.first << "\" is running for "
|
||||
<< absl::ToInt64Seconds(age) << " s";
|
||||
}
|
||||
list_jobs_time_ = current_time;
|
||||
|
||||
@@ -63,9 +63,7 @@ class MediumSocket : public Socket {
|
||||
}
|
||||
|
||||
/** Feeds the received incoming data to the client. */
|
||||
virtual void FeedIncomingData(ByteArray data) {
|
||||
// NEARBY_LOGS(INFO) << "FeedIncomingData: do nothing";
|
||||
}
|
||||
virtual void FeedIncomingData(ByteArray data) {}
|
||||
|
||||
/** Returns true if the socket is a virtual socket. */
|
||||
virtual bool IsVirtualSocket() {
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace nearby {
|
||||
bool TimerImpl::Start(int delay, int period,
|
||||
absl::AnyInvocable<void()> callback) {
|
||||
if (internal_timer_ != nullptr) {
|
||||
NEARBY_LOGS(INFO) << "The timer is already running.";
|
||||
LOG(INFO) << "The timer is already running.";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ bool TimerImpl::Start(int delay, int period,
|
||||
period_ = period;
|
||||
internal_timer_ = api::ImplementationPlatform::CreateTimer();
|
||||
if (!internal_timer_->Create(delay, period, std::move(callback))) {
|
||||
NEARBY_LOGS(INFO) << "Failed to create timer.";
|
||||
LOG(INFO) << "Failed to create timer.";
|
||||
internal_timer_ = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ TEST(UuidTest, CreateFromStringWithMd5) {
|
||||
std::string uuid_str(uuid);
|
||||
std::array<char, 16> uuid_data = uuid.data();
|
||||
std::string md5_data(Crypto::Md5(kString));
|
||||
NEARBY_LOGS(INFO) << "MD5-based UUID: " << uuid_str;
|
||||
LOG(INFO) << "MD5-based UUID: " << uuid_str;
|
||||
uuid_data[6] = 0;
|
||||
uuid_data[8] = 0;
|
||||
md5_data[6] = 0;
|
||||
@@ -66,7 +66,7 @@ TEST(UuidTest, CreateFromBinaryCanOutputString) {
|
||||
Uuid uuid(kCopresenceServiceUuidMsb, kCopresenceServiceUuidLsb);
|
||||
std::array<char, 16> uuid_data = uuid.data();
|
||||
std::string uuid_str(uuid);
|
||||
NEARBY_LOGS(INFO) << "UUID: " << uuid_str;
|
||||
LOG(INFO) << "UUID: " << uuid_str;
|
||||
EXPECT_EQ(uuid_data[0],
|
||||
static_cast<char>((kCopresenceServiceUuidMsb >> 56) & 0xFF));
|
||||
EXPECT_EQ(uuid_data[1],
|
||||
|
||||
@@ -14,12 +14,16 @@
|
||||
|
||||
#include "internal/platform/wifi_direct.h"
|
||||
|
||||
#include "internal/platform/logging.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "internal/platform/cancellation_flag.h"
|
||||
|
||||
namespace nearby {
|
||||
|
||||
WifiDirectSocket WifiDirectMedium::ConnectToService(
|
||||
absl::string_view ip_address, int port,
|
||||
CancellationFlag* cancellation_flag) {
|
||||
NEARBY_LOGS(INFO) << "WifiDirectMedium::ConnectToService: ip address="
|
||||
LOG(INFO) << "WifiDirectMedium::ConnectToService: ip address="
|
||||
<< ip_address << ", port=" << port;
|
||||
return WifiDirectSocket(
|
||||
impl_->ConnectToService(ip_address, port, cancellation_flag));
|
||||
|
||||
@@ -122,7 +122,7 @@ class WifiDirectServerSocket final {
|
||||
WifiDirectSocket Accept() {
|
||||
std::unique_ptr<api::WifiDirectSocket> socket = impl_->Accept();
|
||||
if (!socket) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "WifiDirectServerSocket Accept() failed on server socket: ";
|
||||
}
|
||||
return WifiDirectSocket(std::move(socket));
|
||||
@@ -130,7 +130,7 @@ class WifiDirectServerSocket final {
|
||||
|
||||
// Returns Exception::kIo on error, Exception::kSuccess otherwise.
|
||||
Exception Close() {
|
||||
NEARBY_LOGS(INFO) << "WifiDirectServerSocket Closing:: " << this;
|
||||
LOG(INFO) << "WifiDirectServerSocket Closing:: " << this;
|
||||
return impl_->Close();
|
||||
}
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@ class WifiHotspotServerSocket final {
|
||||
WifiHotspotSocket Accept() {
|
||||
std::unique_ptr<api::WifiHotspotSocket> socket = impl_->Accept();
|
||||
if (!socket) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "WifiHotspotServerSocket Accept() failed on server socket: ";
|
||||
}
|
||||
return WifiHotspotSocket(std::move(socket));
|
||||
@@ -141,7 +141,7 @@ class WifiHotspotServerSocket final {
|
||||
|
||||
// Returns Exception::kIo on error, Exception::kSuccess otherwise.
|
||||
Exception Close() {
|
||||
NEARBY_LOGS(INFO) << "WifiHotspotServerSocket Closing:: " << this;
|
||||
LOG(INFO) << "WifiHotspotServerSocket Closing:: " << this;
|
||||
return impl_->Close();
|
||||
}
|
||||
|
||||
|
||||
@@ -36,14 +36,14 @@ MediumSocket* WifiLanSocket::CreateVirtualSocket(
|
||||
absl::flat_hash_map<std::string, std::shared_ptr<MediumSocket>>*
|
||||
virtual_sockets_ptr) {
|
||||
if (IsVirtualSocket()) {
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< "Creating the virtual socket on a virtual socket is not allowed.";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto virtual_socket = std::make_shared<WifiLanSocket>(outputstream);
|
||||
virtual_socket->impl_ = this->impl_;
|
||||
NEARBY_LOGS(WARNING) << "Created the virtual socket for Medium: "
|
||||
LOG(WARNING) << "Created the virtual socket for Medium: "
|
||||
<< Medium_Name(virtual_socket->GetMedium());
|
||||
|
||||
if (virtual_sockets_ptr_ == nullptr) {
|
||||
@@ -51,7 +51,7 @@ MediumSocket* WifiLanSocket::CreateVirtualSocket(
|
||||
}
|
||||
|
||||
(*virtual_sockets_ptr_)[salted_service_id_hash_key] = virtual_socket;
|
||||
NEARBY_LOGS(INFO) << "virtual_sockets_ size: "
|
||||
LOG(INFO) << "virtual_sockets_ size: "
|
||||
<< virtual_sockets_ptr_->size();
|
||||
return virtual_socket.get();
|
||||
}
|
||||
@@ -70,7 +70,7 @@ bool WifiLanMedium::StartDiscovery(const std::string& service_id,
|
||||
{
|
||||
MutexLock lock(&mutex_);
|
||||
if (service_type_to_callback_map_.contains(service_type)) {
|
||||
NEARBY_LOGS(INFO) << "WifiLan Discovery already start with service_type="
|
||||
LOG(INFO) << "WifiLan Discovery already start with service_type="
|
||||
<< service_type << "; impl=" << &GetImpl();
|
||||
return false;
|
||||
}
|
||||
@@ -84,7 +84,7 @@ bool WifiLanMedium::StartDiscovery(const std::string& service_id,
|
||||
const auto& it = service_type_to_callback_map_.find(service_type);
|
||||
|
||||
if (it == service_type_to_callback_map_.end()) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "There is no callback found for service_type="
|
||||
<< service_type;
|
||||
return;
|
||||
@@ -93,7 +93,7 @@ bool WifiLanMedium::StartDiscovery(const std::string& service_id,
|
||||
// Check whether service name is in cache.
|
||||
auto services_it = service_type_to_services_map_.find(service_type);
|
||||
if (services_it == service_type_to_services_map_.end()) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "There is no service map found for service_type="
|
||||
<< service_type;
|
||||
return;
|
||||
@@ -102,14 +102,14 @@ bool WifiLanMedium::StartDiscovery(const std::string& service_id,
|
||||
std::string service_name = service_info.GetServiceName();
|
||||
auto pair = services_it->second.insert(service_name);
|
||||
if (!pair.second) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Discovering (again) service_info=" << &service_info
|
||||
<< ", service_type=" << service_type
|
||||
<< ", service_name=" << service_info.GetServiceName();
|
||||
return;
|
||||
}
|
||||
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Adding service_info=" << &service_info
|
||||
<< ", service_type=" << service_type
|
||||
<< ", service_name=" << service_info.GetServiceName();
|
||||
@@ -126,7 +126,7 @@ bool WifiLanMedium::StartDiscovery(const std::string& service_id,
|
||||
std::string service_name = service_info.GetServiceName();
|
||||
auto services_it = service_type_to_services_map_.find(service_type);
|
||||
if (services_it == service_type_to_services_map_.end()) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "There is no service map found for service_type="
|
||||
<< service_type;
|
||||
return;
|
||||
@@ -134,7 +134,7 @@ bool WifiLanMedium::StartDiscovery(const std::string& service_id,
|
||||
|
||||
auto item = services_it->second.extract(service_name);
|
||||
if (item.empty()) return;
|
||||
NEARBY_LOGS(INFO) << "Removing service_info=" << &service_info
|
||||
LOG(INFO) << "Removing service_info=" << &service_info
|
||||
<< ", service_type=" << service_type
|
||||
<< ", service_info_name=" << service_name;
|
||||
// Callback service lost.
|
||||
@@ -169,7 +169,7 @@ bool WifiLanMedium::StartDiscovery(const std::string& service_id,
|
||||
service_type_to_callback_map_.erase(service_type);
|
||||
service_type_to_services_map_.erase(service_type);
|
||||
}
|
||||
NEARBY_LOGS(INFO) << "WifiLan Discovery started for service_type="
|
||||
LOG(INFO) << "WifiLan Discovery started for service_type="
|
||||
<< service_type << ", impl=" << &GetImpl()
|
||||
<< ", success=" << success;
|
||||
return success;
|
||||
@@ -184,7 +184,7 @@ bool WifiLanMedium::StopDiscovery(const std::string& service_type) {
|
||||
if (service_type_to_services_map_.contains(service_type)) {
|
||||
service_type_to_services_map_.erase(service_type);
|
||||
}
|
||||
NEARBY_LOGS(INFO) << "WifiLan Discovery disabled for service_type="
|
||||
LOG(INFO) << "WifiLan Discovery disabled for service_type="
|
||||
<< service_type << ", impl=" << &GetImpl();
|
||||
return impl_->StopDiscovery(service_type);
|
||||
}
|
||||
@@ -192,7 +192,7 @@ bool WifiLanMedium::StopDiscovery(const std::string& service_type) {
|
||||
WifiLanSocket WifiLanMedium::ConnectToService(
|
||||
const NsdServiceInfo& remote_service_info,
|
||||
CancellationFlag* cancellation_flag) {
|
||||
NEARBY_LOGS(INFO) << "WifiLanMedium::ConnectToService: remote_service_name="
|
||||
LOG(INFO) << "WifiLanMedium::ConnectToService: remote_service_name="
|
||||
<< remote_service_info.GetServiceName();
|
||||
return WifiLanSocket(
|
||||
impl_->ConnectToService(remote_service_info, cancellation_flag));
|
||||
@@ -201,7 +201,7 @@ WifiLanSocket WifiLanMedium::ConnectToService(
|
||||
WifiLanSocket WifiLanMedium::ConnectToService(
|
||||
const std::string& ip_address, int port,
|
||||
CancellationFlag* cancellation_flag) {
|
||||
NEARBY_LOGS(INFO) << "WifiLanMedium::ConnectToService: ip address="
|
||||
LOG(INFO) << "WifiLanMedium::ConnectToService: ip address="
|
||||
<< WifiUtils::GetHumanReadableIpAddress(ip_address)
|
||||
<< ", port=" << port;
|
||||
return WifiLanSocket(
|
||||
|
||||
@@ -82,7 +82,7 @@ class WifiLanSocket : public MediumSocket {
|
||||
// Returns Exception::kIo on error, Exception::kSuccess otherwise.
|
||||
Exception Close() override {
|
||||
if (IsVirtualSocket()) {
|
||||
NEARBY_LOGS(INFO) << "Multiplex: Closing virtual socket: " << this;
|
||||
LOG(INFO) << "Multiplex: Closing virtual socket: " << this;
|
||||
blocking_queue_input_stream_->Close();
|
||||
virtual_output_stream_->Close();
|
||||
CloseLocal(); // This will trigger MultiplexSocket::OnVirtualSocketClosed
|
||||
@@ -104,7 +104,7 @@ class WifiLanSocket : public MediumSocket {
|
||||
/** Feeds the received incoming data to the client. */
|
||||
void FeedIncomingData(ByteArray data) override {
|
||||
if (!IsVirtualSocket()) {
|
||||
NEARBY_LOGS(INFO) << "Feeding data on a physical socket is not allowed.";
|
||||
LOG(INFO) << "Feeding data on a physical socket is not allowed.";
|
||||
return;
|
||||
}
|
||||
blocking_queue_input_stream_->Write(data);
|
||||
@@ -164,7 +164,7 @@ class WifiLanServerSocket final {
|
||||
WifiLanSocket Accept() {
|
||||
std::unique_ptr<api::WifiLanSocket> socket = impl_->Accept();
|
||||
if (!socket) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "WifiLanServerSocket Accept() failed on server socket: " << this;
|
||||
}
|
||||
return WifiLanSocket(std::move(socket));
|
||||
@@ -172,7 +172,7 @@ class WifiLanServerSocket final {
|
||||
|
||||
// Returns Exception::kIo on error, Exception::kSuccess otherwise.
|
||||
Exception Close() {
|
||||
NEARBY_LOGS(INFO) << "WifiLanServerSocket Closing:: " << this;
|
||||
LOG(INFO) << "WifiLanServerSocket Closing:: " << this;
|
||||
return impl_->Close();
|
||||
}
|
||||
|
||||
|
||||
@@ -38,27 +38,27 @@ bool Compare(const Descriptor* desc1, const Descriptor* desc2);
|
||||
// or type is different.
|
||||
bool Compare(const FieldDescriptor* field1, const FieldDescriptor* field2) {
|
||||
if (field1->name() != field2->name()) {
|
||||
NEARBY_LOGS(WARNING) << "Field name diff: " << field1->name() << " <=> "
|
||||
<< field2->name();
|
||||
LOG(WARNING) << "Field name diff: " << field1->name() << " <=> "
|
||||
<< field2->name();
|
||||
return false;
|
||||
}
|
||||
if (field1->number() != field2->number()) {
|
||||
NEARBY_LOGS(WARNING) << "Field " << field1->name()
|
||||
<< " number diff: " << field1->number() << " <=> "
|
||||
<< field2->number();
|
||||
LOG(WARNING) << "Field " << field1->name()
|
||||
<< " number diff: " << field1->number() << " <=> "
|
||||
<< field2->number();
|
||||
return false;
|
||||
}
|
||||
if (field1->label() != field2->label()) {
|
||||
NEARBY_LOGS(WARNING) << "Field " << field1->name()
|
||||
<< " label diff: " << field1->label() << " <=> "
|
||||
<< field2->label();
|
||||
LOG(WARNING) << "Field " << field1->name()
|
||||
<< " label diff: " << field1->label() << " <=> "
|
||||
<< field2->label();
|
||||
return false;
|
||||
}
|
||||
bool bRet = false;
|
||||
if (field1->type() != field2->type()) {
|
||||
NEARBY_LOGS(WARNING) << "Field " << field1->name()
|
||||
<< " type diff: " << field1->type() << " <=> "
|
||||
<< field2->type();
|
||||
LOG(WARNING) << "Field " << field1->name()
|
||||
<< " type diff: " << field1->type() << " <=> "
|
||||
<< field2->type();
|
||||
return bRet;
|
||||
} else if (field1->type() == FieldDescriptor::TYPE_MESSAGE) {
|
||||
const Descriptor* msg1 = field1->message_type();
|
||||
@@ -74,8 +74,8 @@ bool Compare(const FieldDescriptor* field1, const FieldDescriptor* field2) {
|
||||
|
||||
// Compares the two descriptors and return false immediately if different.
|
||||
bool Compare(const Descriptor* desc1, const Descriptor* desc2) {
|
||||
NEARBY_LOGS(INFO) << "Descriptor1 full name: " << desc1->full_name()
|
||||
<< " <=> " << desc2->full_name();
|
||||
LOG(INFO) << "Descriptor1 full name: " << desc1->full_name() << " <=> "
|
||||
<< desc2->full_name();
|
||||
for (int i = 0; i < desc1->field_count(); ++i) {
|
||||
const FieldDescriptor* field1 = desc1->field(i);
|
||||
const FieldDescriptor* field2 = desc2->FindFieldByName(field1->name());
|
||||
@@ -84,11 +84,11 @@ bool Compare(const Descriptor* desc1, const Descriptor* desc2) {
|
||||
if (field2) {
|
||||
bRet = Compare(field1, field2);
|
||||
} else {
|
||||
NEARBY_LOGS(ERROR) << "Descriptor1 full name: " << desc1->full_name()
|
||||
<< "=> Extra field1 name=" << field1->name()
|
||||
<< ", number=" << field1->number()
|
||||
<< ", label=" << field1->label()
|
||||
<< ", type=" << field1->type();
|
||||
LOG(ERROR) << "Descriptor1 full name: " << desc1->full_name()
|
||||
<< "=> Extra field1 name=" << field1->name()
|
||||
<< ", number=" << field1->number()
|
||||
<< ", label=" << field1->label()
|
||||
<< ", type=" << field1->type();
|
||||
}
|
||||
if (!bRet) {
|
||||
return false;
|
||||
@@ -98,11 +98,11 @@ bool Compare(const Descriptor* desc1, const Descriptor* desc2) {
|
||||
const FieldDescriptor* field2 = desc2->field(i);
|
||||
const FieldDescriptor* field1 = desc1->FindFieldByName(field2->name());
|
||||
if (!field1) {
|
||||
NEARBY_LOGS(ERROR) << "Descriptor2 full name: " << desc2->full_name()
|
||||
<< "=> Extra field2 name=" << field2->name()
|
||||
<< ", number=" << field2->number()
|
||||
<< ", label=" << field2->label()
|
||||
<< ", type=" << field2->type();
|
||||
LOG(ERROR) << "Descriptor2 full name: " << desc2->full_name()
|
||||
<< "=> Extra field2 name=" << field2->name()
|
||||
<< ", number=" << field2->number()
|
||||
<< ", label=" << field2->label()
|
||||
<< ", type=" << field2->type();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ bool FakeTimer::InternalStart(int delay, int period,
|
||||
}
|
||||
|
||||
if (!timer_data_.id.empty()) {
|
||||
NEARBY_LOGS(ERROR) << __func__ << ": timer is already running";
|
||||
LOG(ERROR) << __func__ << ": timer is already running";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -80,13 +80,13 @@ BaseSocket::BaseSocket(const Connection& connection, SocketCallback&& callback)
|
||||
}
|
||||
|
||||
BaseSocket::~BaseSocket() {
|
||||
NEARBY_LOGS(INFO) << "~BaseSocket";
|
||||
LOG(INFO) << "~BaseSocket";
|
||||
ShutDown();
|
||||
}
|
||||
|
||||
void BaseSocket::ShutDown() {
|
||||
executor_.Shutdown();
|
||||
NEARBY_LOGS(INFO) << "BaseSocket gone.";
|
||||
LOG(INFO) << "BaseSocket gone.";
|
||||
}
|
||||
|
||||
void BaseSocket::TryWriteNextControl() {
|
||||
@@ -136,11 +136,11 @@ void BaseSocket::TryWriteNextMessage() {
|
||||
|
||||
void BaseSocket::WritePacket(absl::StatusOr<Packet> packet) {
|
||||
if (!packet.ok()) {
|
||||
NEARBY_LOGS(WARNING) << "Packet status:" << packet.status();
|
||||
LOG(WARNING) << "Packet status:" << packet.status();
|
||||
return;
|
||||
}
|
||||
CHECK_OK(packet->SetPacketCounter(packet_counter_generator_.Next()));
|
||||
NEARBY_LOGS(INFO) << "transmitting packet";
|
||||
LOG(INFO) << "transmitting packet";
|
||||
connection_.Transmit(packet->GetBytes());
|
||||
}
|
||||
|
||||
@@ -155,13 +155,13 @@ void BaseSocket::OnWriteRequestWriteComplete(absl::Status status) {
|
||||
current_control_ = nullptr;
|
||||
control_request_queue_.pop_front();
|
||||
} else if (current_message_ != nullptr) {
|
||||
NEARBY_LOGS(INFO) << "OnWriteResult current is not null";
|
||||
LOG(INFO) << "OnWriteResult current is not null";
|
||||
if (current_message_->IsFinished()) {
|
||||
NEARBY_LOGS(INFO) << "OnWriteResult current finished";
|
||||
LOG(INFO) << "OnWriteResult current finished";
|
||||
current_message_->SetWriteStatus(status);
|
||||
if (!message_request_queue_.empty() &&
|
||||
current_message_ == &message_request_queue_.front()) {
|
||||
NEARBY_LOGS(INFO) << "remove message";
|
||||
LOG(INFO) << "remove message";
|
||||
message_request_queue_.pop_front();
|
||||
current_message_ = nullptr;
|
||||
}
|
||||
@@ -231,9 +231,9 @@ void BaseSocket::DisconnectQuietly() {
|
||||
current_message_ = nullptr;
|
||||
state_ = SocketConnectionState::kDisconnected;
|
||||
}
|
||||
NEARBY_LOGS(INFO) << "Socket now disconnected.";
|
||||
LOG(INFO) << "Socket now disconnected.";
|
||||
});
|
||||
NEARBY_LOGS(INFO) << "scheduled reset";
|
||||
LOG(INFO) << "scheduled reset";
|
||||
}
|
||||
|
||||
void BaseSocket::OnReceiveDataPacket(Packet packet) {
|
||||
@@ -280,7 +280,7 @@ void BaseSocket::WriteControlPacket(Packet packet) {
|
||||
}
|
||||
TryWriteNextControl();
|
||||
});
|
||||
NEARBY_LOGS(INFO) << "Scheduled TryWriteControl";
|
||||
LOG(INFO) << "Scheduled TryWriteControl";
|
||||
}
|
||||
|
||||
void BaseSocket::DisconnectInternal(absl::Status status) {
|
||||
|
||||
@@ -61,7 +61,7 @@ class BaseSocket {
|
||||
void WriteControlPacket(Packet packet);
|
||||
void OnReceiveDataPacket(Packet packet);
|
||||
void RunOnSocketThread(std::string name, Runnable&& runnable) {
|
||||
NEARBY_LOGS(INFO) << "RunOnSocketThread: " << name;
|
||||
LOG(INFO) << "RunOnSocketThread: " << name;
|
||||
executor_.Execute(name, std::move(runnable));
|
||||
}
|
||||
void ShutDown();
|
||||
|
||||
@@ -63,7 +63,7 @@ class FakeConnection : public Connection {
|
||||
packets_written_.erase(packets_written_.begin());
|
||||
return front;
|
||||
}
|
||||
NEARBY_LOGS(WARNING) << "No more packets";
|
||||
LOG(WARNING) << "No more packets";
|
||||
return "";
|
||||
}
|
||||
bool NoMorePackets() {
|
||||
@@ -143,7 +143,7 @@ class BaseSocketTest : public ::testing::Test {
|
||||
.on_error_cb =
|
||||
[this](absl::Status status) {
|
||||
error_status_ = status;
|
||||
NEARBY_LOGS(ERROR) << status;
|
||||
LOG(ERROR) << status;
|
||||
},
|
||||
}) {}
|
||||
void TransmitAndFail() {
|
||||
@@ -282,7 +282,7 @@ TEST_F(BaseSocketTest, TestWritePacketCounterRollover) {
|
||||
Packet packet = Packet::CreateDataPacket(true, true, ByteArray("\x01"));
|
||||
EXPECT_OK(packet.SetPacketCounter(i));
|
||||
nearby::Future<absl::Status> result = socket_.Write(ByteArray("\x01"));
|
||||
NEARBY_LOGS(INFO) << "sent packet " << i;
|
||||
LOG(INFO) << "sent packet " << i;
|
||||
EXPECT_OK(result.Get().GetResult());
|
||||
EXPECT_EQ(connection_.PollWrittenPacket(), packet.GetBytes());
|
||||
}
|
||||
@@ -327,7 +327,7 @@ TEST_F(BaseSocketTest, TestResetByDisconnect) {
|
||||
|
||||
// connect again
|
||||
socket_.OnConnectedProxy(kMaxPacketSize);
|
||||
NEARBY_LOGS(INFO) << "Reconnected socket";
|
||||
LOG(INFO) << "Reconnected socket";
|
||||
// sleep for 10 ms to allow for packet population
|
||||
absl::SleepFor(absl::Milliseconds(10));
|
||||
EXPECT_EQ(connection_.PollWrittenPacket(), "");
|
||||
@@ -445,18 +445,18 @@ TEST_F(BaseSocketTest, TestOnRemoteTransitEmpty) {
|
||||
TEST_F(BaseSocketTest, TestReconnect) {
|
||||
connection_.SetInstantTransmit(false);
|
||||
socket_.OnConnectedProxy(kMaxPacketSize);
|
||||
NEARBY_LOGS(INFO) << "Starting TransmitAndFail1";
|
||||
LOG(INFO) << "Starting TransmitAndFail1";
|
||||
TransmitAndFail();
|
||||
NEARBY_LOGS(INFO) << "TransmitAndFail1 completed";
|
||||
LOG(INFO) << "TransmitAndFail1 completed";
|
||||
connection_.OnTransmitProxy(absl::UnavailableError(""));
|
||||
EXPECT_EQ(error_status_.code(), absl::StatusCode::kUnavailable);
|
||||
absl::SleepFor(absl::Milliseconds(20));
|
||||
NEARBY_LOGS(INFO) << "Reconnecting";
|
||||
LOG(INFO) << "Reconnecting";
|
||||
socket_.OnConnectedProxy(kMaxPacketSize);
|
||||
absl::SleepFor(absl::Milliseconds(20));
|
||||
NEARBY_LOGS(INFO) << "Starting transmit and fail 2";
|
||||
LOG(INFO) << "Starting transmit and fail 2";
|
||||
TransmitAndFail();
|
||||
NEARBY_LOGS(INFO) << "TransmitAndFail2 completed";
|
||||
LOG(INFO) << "TransmitAndFail2 completed";
|
||||
absl::SleepFor(absl::Milliseconds(10));
|
||||
EXPECT_TRUE(connection_.NoMorePackets());
|
||||
}
|
||||
|
||||
@@ -26,16 +26,16 @@ namespace weave {
|
||||
|
||||
struct SocketCallback {
|
||||
std::function<void()> on_connected_cb = []() {
|
||||
NEARBY_LOGS(WARNING) << "Unimplemented!";
|
||||
LOG(WARNING) << "Unimplemented!";
|
||||
};
|
||||
std::function<void()> on_disconnected_cb = []() {
|
||||
NEARBY_LOGS(WARNING) << "Unimplemented!";
|
||||
LOG(WARNING) << "Unimplemented!";
|
||||
};
|
||||
std::function<void(std::string message)> on_receive_cb = [](std::string) {
|
||||
NEARBY_LOGS(WARNING) << "Unimplemented!";
|
||||
LOG(WARNING) << "Unimplemented!";
|
||||
};
|
||||
std::function<void(absl::Status)> on_error_cb = [](absl::Status) {
|
||||
NEARBY_LOGS(WARNING) << "Unimplemented!";
|
||||
LOG(WARNING) << "Unimplemented!";
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ ClientSocket::ClientSocket(
|
||||
ClientSocket::~ClientSocket() {
|
||||
ShutDown();
|
||||
executor_.Shutdown();
|
||||
NEARBY_LOGS(INFO) << "ClientSocket gone.";
|
||||
LOG(INFO) << "ClientSocket gone.";
|
||||
}
|
||||
|
||||
void ClientSocket::Connect() {
|
||||
|
||||
@@ -76,7 +76,7 @@ class FakeConnection : public Connection {
|
||||
packets_written_.erase(packets_written_.begin());
|
||||
return front;
|
||||
}
|
||||
NEARBY_LOGS(WARNING) << "No more packets";
|
||||
LOG(WARNING) << "No more packets";
|
||||
return "";
|
||||
}
|
||||
bool NoMorePackets() {
|
||||
@@ -123,7 +123,7 @@ class ClientSocketTest : public ::testing::Test {
|
||||
.on_error_cb =
|
||||
[this](absl::Status status) {
|
||||
last_error_ = status;
|
||||
NEARBY_LOGS(ERROR) << status;
|
||||
LOG(ERROR) << status;
|
||||
},
|
||||
})) {}
|
||||
void SetUp() override { EXPECT_FALSE(socket_.IsConnected()); }
|
||||
@@ -134,7 +134,7 @@ class ClientSocketTest : public ::testing::Test {
|
||||
void RunConnect(int client_size, int server_size,
|
||||
absl::string_view initial_data) {
|
||||
connection_.SetMaxPacketSize(client_size);
|
||||
NEARBY_LOGS(INFO) << "connect";
|
||||
LOG(INFO) << "connect";
|
||||
socket_.Connect();
|
||||
absl::SleepFor(absl::Milliseconds(10));
|
||||
auto packet = Packet::FromBytes(ByteArray(connection_.PollWrittenPacket()));
|
||||
@@ -350,7 +350,7 @@ TEST_F(ClientSocketTest, TestSocketWithRandomDataProvider) {
|
||||
messages_read_.push_back(message);
|
||||
},
|
||||
.on_error_cb =
|
||||
[](absl::Status status) { NEARBY_LOGS(ERROR) << status; },
|
||||
[](absl::Status status) { LOG(ERROR) << status; },
|
||||
},
|
||||
std::move(provider));
|
||||
socket.Connect();
|
||||
|
||||
@@ -67,7 +67,7 @@ ServerSocket::ServerSocket(const Connection& connection,
|
||||
: BaseSocket(connection, std::move(socket_callback)) {}
|
||||
|
||||
ServerSocket::~ServerSocket() {
|
||||
NEARBY_LOGS(INFO) << "ServerSocket dtor";
|
||||
LOG(INFO) << "ServerSocket dtor";
|
||||
ShutDown();
|
||||
}
|
||||
|
||||
@@ -79,14 +79,14 @@ void ServerSocket::DisconnectQuietly() {
|
||||
void ServerSocket::OnReceiveControlPacket(Packet packet) {
|
||||
if (packet.GetControlCommandNumber() ==
|
||||
Packet::ControlPacketType::kControlError) {
|
||||
NEARBY_LOGS(WARNING) << "Received error control packet, disconnecting.";
|
||||
LOG(WARNING) << "Received error control packet, disconnecting.";
|
||||
DisconnectQuietly();
|
||||
return;
|
||||
}
|
||||
// Control packets besides errors are not supposed to be sent or received
|
||||
// after the initial handshake.
|
||||
if (state_ != State::kClientConnectionRequest) {
|
||||
NEARBY_LOGS(ERROR) << "Not in 'Connection Request' state, but "
|
||||
LOG(ERROR) << "Not in 'Connection Request' state, but "
|
||||
"incorrectly received control packet of type "
|
||||
<< Packet::ControlPacketTypeToString(
|
||||
packet.GetControlCommandNumber());
|
||||
@@ -96,7 +96,7 @@ void ServerSocket::OnReceiveControlPacket(Packet packet) {
|
||||
}
|
||||
if (packet.GetControlCommandNumber() !=
|
||||
Packet::ControlPacketType::kControlConnectionRequest) {
|
||||
NEARBY_LOGS(ERROR) << "Expected connection request control packet, "
|
||||
LOG(ERROR) << "Expected connection request control packet, "
|
||||
"received control packet of type "
|
||||
<< Packet::ControlPacketTypeToString(
|
||||
packet.GetControlCommandNumber());
|
||||
@@ -116,7 +116,7 @@ void ServerSocket::OnReceiveControlPacket(Packet packet) {
|
||||
ExtractMaxProtocolVersionFromConnRequest(packet_payload);
|
||||
if (min_protocol_version > kProtocolVersion ||
|
||||
max_protocol_version < kProtocolVersion) {
|
||||
NEARBY_LOGS(ERROR) << "Received unexpected min/max protocol versions: "
|
||||
LOG(ERROR) << "Received unexpected min/max protocol versions: "
|
||||
<< min_protocol_version << " and "
|
||||
<< max_protocol_version;
|
||||
DisconnectInternal(
|
||||
@@ -144,7 +144,7 @@ void ServerSocket::WriteConnectionConfirm() {
|
||||
absl::StatusOr<Packet> packet = Packet::CreateConnectionConfirmPacket(
|
||||
kProtocolVersion, max_packet_size_, "");
|
||||
if (!packet.ok()) {
|
||||
NEARBY_LOGS(ERROR) << "Failed to create connection confirm packet: "
|
||||
LOG(ERROR) << "Failed to create connection confirm packet: "
|
||||
<< packet.status();
|
||||
DisconnectInternal(packet.status());
|
||||
return;
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "protobuf-matchers/protocol-buffer-matchers.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "absl/synchronization/mutex.h"
|
||||
#include "internal/platform/logging.h"
|
||||
|
||||
namespace nearby {
|
||||
namespace weave {
|
||||
@@ -69,7 +70,7 @@ class FakeConnection : public Connection {
|
||||
packets_written_.erase(packets_written_.begin());
|
||||
return front;
|
||||
}
|
||||
NEARBY_LOGS(WARNING) << "No more packets";
|
||||
LOG(WARNING) << "No more packets";
|
||||
return "";
|
||||
}
|
||||
bool NoMorePackets() {
|
||||
@@ -116,7 +117,7 @@ class ServerSocketTest : public ::testing::Test {
|
||||
.on_error_cb =
|
||||
[this](absl::Status status) {
|
||||
last_error_ = status;
|
||||
NEARBY_LOGS(ERROR) << status;
|
||||
LOG(ERROR) << status;
|
||||
},
|
||||
})) {}
|
||||
void SetUp() override { EXPECT_FALSE(socket_.IsConnected()); }
|
||||
|
||||
Reference in New Issue
Block a user