Replace NEARBY_LOGS with LOG for all coding under google3/third_party/nearby/

PiperOrigin-RevId: 786733783
This commit is contained in:
hai007
2025-07-24 09:34:17 -07:00
committed by Copybara-Service
parent a78e9e4138
commit 71cdf84236
116 changed files with 1227 additions and 1232 deletions
+19 -19
View File
@@ -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()});
+18 -18
View File
@@ -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;
}