Remove more unnecessary INFO logs.

PiperOrigin-RevId: 797859361
This commit is contained in:
Francis Tsui
2025-08-21 12:04:13 -07:00
committed by Copybara-Service
parent adf211a891
commit 3f93c0ee87
22 changed files with 365 additions and 390 deletions
@@ -315,25 +315,17 @@ bool BleV2Medium::StartAdvertising(const BleAdvertisementData& advertising_data,
absl::BytesToHexString(it.second.AsStringView()) + "}";
}
LOG(INFO) << __func__
<< ": advertising_data.service_data=" << service_data_info
<< ", tx_power_level="
<< TxPowerLevelToName(advertising_parameters.tx_power_level);
VLOG(1) << __func__ << ": advertising_data.service_data=" << service_data_info
<< ", tx_power_level="
<< TxPowerLevelToName(advertising_parameters.tx_power_level);
if (advertising_data.is_extended_advertisement) {
if (advertising_data.is_extended_advertisement ||
ble_gatt_server_ == nullptr) {
// In BLE v2, the flag is set when the Bluetooth adapter supports extended
// advertising and GATT server is using.
LOG(INFO) << __func__ << ": BLE advertising using BLE extended feature.";
return StartBleAdvertising(advertising_data, advertising_parameters);
} else {
if (ble_gatt_server_ != nullptr) {
LOG(INFO) << __func__ << ": BLE advertising on GATT server.";
return StartGattAdvertising(advertising_data, advertising_parameters);
} else {
LOG(INFO) << __func__ << ": BLE fast advertising.";
return StartBleAdvertising(advertising_data, advertising_parameters);
}
}
return StartGattAdvertising(advertising_data, advertising_parameters);
}
bool BleV2Medium::StopAdvertising() {
@@ -641,7 +633,7 @@ bool BleV2Medium::StopScanning() {
std::unique_ptr<api::ble_v2::BleServerSocket> BleV2Medium::OpenServerSocket(
const std::string& service_id) {
LOG(INFO) << "OpenServerSocket is called";
VLOG(1) << "OpenServerSocket is called";
auto server_socket = std::make_unique<BleV2ServerSocket>(adapter_);
@@ -691,7 +683,8 @@ bool BleV2Medium::IsExtendedAdvertisementsAvailable() {
bool BleV2Medium::StartBleAdvertising(
const api::ble_v2::BleAdvertisementData& advertising_data,
api::ble_v2::AdvertiseParameters advertising_parameters) {
LOG(INFO) << __func__ << ": Start BLE advertising.";
LOG(INFO) << __func__ << ": Start BLE advertising, extended:"
<< advertising_data.is_extended_advertisement;
try {
if (!adapter_->IsEnabled()) {
LOG(WARNING) << "BLE cannot start advertising because the "
@@ -725,7 +718,7 @@ bool BleV2Medium::StartBleAdvertising(
LOG(WARNING) << "BLE failed to get service UUID.";
return false;
}
LOG(WARNING) << "BLE service UUID: " << absl::StrCat(absl::Hex(*uuid16));
VLOG(1) << "BLE service UUID: " << absl::StrCat(absl::Hex(*uuid16));
data_writer.WriteUInt16(*uuid16);
@@ -38,7 +38,7 @@ BleV2ServerSocket::BleV2ServerSocket(api::BluetoothAdapter* adapter)
std::unique_ptr<api::ble_v2::BleSocket> BleV2ServerSocket::Accept() {
absl::MutexLock lock(&mutex_);
LOG(INFO) << __func__ << ": Accept is called.";
VLOG(1) << __func__ << ": Accept is called.";
while (!closed_ && pending_sockets_.empty()) {
cond_.Wait(&mutex_);
@@ -55,7 +55,7 @@ std::unique_ptr<api::ble_v2::BleSocket> BleV2ServerSocket::Accept() {
Exception BleV2ServerSocket::Close() {
// TODO(b/271031645): implement BLE socket using weave
absl::MutexLock lock(&mutex_);
LOG(INFO) << __func__ << ": Close is called.";
VLOG(1) << __func__ << ": Close is called.";
if (closed_) {
return {Exception::kSuccess};
@@ -108,8 +108,8 @@ BluetoothAdapter::BluetoothAdapter() : windows_bluetooth_adapter_(nullptr) {
// Synchronously sets the status of the BluetoothAdapter to 'status', and
// returns true if the operation was a success.
bool BluetoothAdapter::SetStatus(Status status) {
LOG(ERROR) << __func__ << ": Set Bluetooth radio status to "
<< (status == Status::kEnabled ? "On" : "Off");
LOG(INFO) << __func__ << ": Set Bluetooth radio status to "
<< (status == Status::kEnabled ? "On" : "Off");
if (windows_bluetooth_radio_ == nullptr) {
LOG(ERROR) << __func__ << ": No Bluetooth radio on this device.";
return false;
@@ -120,23 +120,23 @@ bool BluetoothAdapter::SetStatus(Status status) {
if (status == Status::kDisabled &&
(radio_state == RadioState::Unknown || radio_state == RadioState::Off ||
radio_state == RadioState::Disabled)) {
LOG(INFO) << __func__
<< ": Skip set radio status kDisabled due to requested state is "
"already kDisabled.";
VLOG(1) << __func__
<< ": Skip set radio status kDisabled due to requested state is "
"already kDisabled.";
return true;
}
if (status == Status::kEnabled && radio_state == RadioState::On) {
LOG(INFO) << __func__
<< ": Skip set radio status kEnabled due to requested state is "
"already kEnabled.";
VLOG(1) << __func__
<< ": Skip set radio status kEnabled due to requested state is "
"already kEnabled.";
return true;
}
if (!FeatureFlags::GetInstance().GetFlags().enable_set_radio_state) {
LOG(INFO) << __func__
<< ": Attempt to set the radio state while "
"FeatureFlags::enable_set_radio_state is false.";
VLOG(1) << __func__
<< ": Attempt to set the radio state while "
"FeatureFlags::enable_set_radio_state is false.";
return false;
}
@@ -497,9 +497,9 @@ bool BluetoothAdapter::SetName(absl::string_view name, bool persist) {
device_name_ = std::nullopt;
if (registry_bluetooth_adapter_name_ == name) {
LOG(INFO) << __func__
<< ": Tried to set name for bluetooth adapter to the "
"same name again.";
VLOG(1) << __func__
<< ": Tried to set name for bluetooth adapter to the "
"same name again.";
return true;
}
@@ -871,7 +871,8 @@ std::string BluetoothAdapter::GetNameFromRegistry(PHKEY hKey) const {
// parameter, in bytes.
if (status != ERROR_SUCCESS) {
LOG(ERROR) << __func__
<< ": Failed to get the required size of the local name buffer";
<< ": Failed to get the required size of the local name buffer: "
<< status;
return "";
}
unsigned char *local_name = new unsigned char[local_name_size];
@@ -117,7 +117,7 @@ BluetoothClassicMedium::~BluetoothClassicMedium() {}
bool BluetoothClassicMedium::StartDiscovery(
BluetoothClassicMedium::DiscoveryCallback discovery_callback) {
LOG(INFO) << "StartDiscovery is called.";
VLOG(1) << "StartDiscovery is called.";
bool result = false;
discovery_callback_ = std::move(discovery_callback);
@@ -130,7 +130,7 @@ bool BluetoothClassicMedium::StartDiscovery(
}
bool BluetoothClassicMedium::StopDiscovery() {
LOG(INFO) << "StopDiscovery is called.";
VLOG(1) << "StopDiscovery is called.";
bool result = false;
@@ -251,8 +251,8 @@ std::unique_ptr<api::BluetoothSocket> BluetoothClassicMedium::ConnectToService(
std::unique_ptr<api::BluetoothServerSocket>
BluetoothClassicMedium::ListenForService(const std::string& service_name,
const std::string& service_uuid) {
LOG(INFO) << "ListenForService is called with service name: " << service_name
<< ".";
VLOG(1) << "ListenForService is called with service name: " << service_name
<< ".";
if (service_uuid.empty()) {
LOG(ERROR) << __func__ << ": service_uuid was empty.";
return nullptr;
@@ -268,7 +268,7 @@ BluetoothClassicMedium::ListenForService(const std::string& service_name,
scan_mode_ = bluetooth_adapter_.GetScanMode();
LOG(INFO) << __func__ << ": scan_mode: " << static_cast<int>(scan_mode_);
VLOG(1) << __func__ << ": scan_mode: " << static_cast<int>(scan_mode_);
bool radio_discoverable =
scan_mode_ == BluetoothAdapter::ScanMode::kConnectableDiscoverable;
@@ -284,7 +284,7 @@ BluetoothClassicMedium::ListenForService(const std::string& service_name,
api::BluetoothDevice* BluetoothClassicMedium::GetRemoteDevice(
const std::string& mac_address) {
LOG(INFO) << "GetRemoteDevice is called with mac_address: " << mac_address;
VLOG(1) << "GetRemoteDevice is called with mac_address: " << mac_address;
return GetRemoteDeviceInternal(mac_address);
}
@@ -371,7 +371,7 @@ void BluetoothClassicMedium::OnScanModeChanged(
<< static_cast<int>(scan_mode);
if (scan_mode == scan_mode_) {
LOG(INFO) << __func__ << ": No change of scan mode.";
VLOG(1) << __func__ << ": No change of scan mode.";
return;
}
@@ -387,7 +387,7 @@ void BluetoothClassicMedium::OnScanModeChanged(
}
if (is_radio_discoverable_ == radio_discoverable) {
LOG(INFO) << __func__ << ": No change of radio discovery.";
VLOG(1) << __func__ << ": No change of radio discovery.";
return;
}
@@ -918,7 +918,7 @@ bool BluetoothClassicMedium::StartAdvertising(bool radio_discoverable) {
}
bool BluetoothClassicMedium::StopAdvertising() {
LOG(INFO) << __func__ << ": StopAdvertising is called";
VLOG(1) << __func__ << ": StopAdvertising is called";
try {
if (rfcomm_provider_ == nullptr) {
@@ -51,8 +51,8 @@ BluetoothServerSocket::~BluetoothServerSocket() { Close(); }
// Returns nullptr on error.
// Once error is reported, it is permanent, and ServerSocket has to be closed.
std::unique_ptr<api::BluetoothSocket> BluetoothServerSocket::Accept() {
absl::MutexLock lock(&mutex_);
LOG(INFO) << __func__ << ": Accept is called.";
absl::MutexLock lock(mutex_);
VLOG(1) << __func__ << ": Accept is called.";
while (!closed_ && pending_sockets_.empty()) {
cond_.Wait(&mutex_);
@@ -74,8 +74,8 @@ void BluetoothServerSocket::SetCloseNotifier(
// Returns Exception::kIo on error, Exception::kSuccess otherwise.
Exception BluetoothServerSocket::Close() {
try {
absl::MutexLock lock(&mutex_);
LOG(INFO) << __func__ << ": Close is called.";
absl::MutexLock lock(mutex_);
VLOG(1) << __func__ << ": Close is called.";
if (closed_) {
return {Exception::kSuccess};
@@ -155,7 +155,7 @@ bool BluetoothServerSocket::listen() {
::winrt::fire_and_forget BluetoothServerSocket::Listener_ConnectionReceived(
StreamSocketListener listener,
StreamSocketListenerConnectionReceivedEventArgs const& args) {
absl::MutexLock lock(&mutex_);
absl::MutexLock lock(mutex_);
LOG(INFO) << __func__ << ": Received connection.";
if (closed_) {
@@ -43,7 +43,7 @@ NearbyServerSocket::~NearbyServerSocket() {
}
bool NearbyServerSocket::Listen(const std::string& ip_address, int port) {
LOG(INFO) << "Listen to socket at " << ip_address << ":" << port;
VLOG(1) << "Listen to socket at " << ip_address << ":" << port;
if (!is_socket_initiated_) {
LOG(ERROR) << "Windows socket is not initiated.";
return false;
@@ -87,7 +87,7 @@ bool NearbyServerSocket::Listen(const std::string& ip_address, int port) {
ip_address_ = ip_address;
port_ = ntohs(local_address.sin_port);
LOG(INFO) << "Bound to " << ip_address_ << ":" << port_;
VLOG(1) << "Bound to " << ip_address_ << ":" << port_;
if (::listen(/*s=*/socket_, /*backlog=*/SOMAXCONN) == SOCKET_ERROR) {
LOG(ERROR) << "Failed to listen socket with error " << WSAGetLastError();
@@ -99,7 +99,7 @@ bool NearbyServerSocket::Listen(const std::string& ip_address, int port) {
}
std::unique_ptr<NearbyClientSocket> NearbyServerSocket::Accept() {
LOG(INFO) << "Accept is called on NearbyServerSocket.";
VLOG(1) << "Accept is called on NearbyServerSocket.";
if (!is_socket_initiated_) {
LOG(WARNING) << "Windows socket is not initiated";
return nullptr;
@@ -120,7 +120,7 @@ std::unique_ptr<NearbyClientSocket> NearbyServerSocket::Accept() {
inet_ntop(AF_INET, &(peer_address.sin_addr), client_ip, INET_ADDRSTRLEN);
int client_port = ntohs(peer_address.sin_port);
LOG(INFO) << "Accepted emote device " << client_ip << ":" << client_port;
LOG(INFO) << "Accepted remote device " << client_ip << ":" << client_port;
return std::make_unique<NearbyClientSocket>(client_socket);
}
@@ -113,11 +113,11 @@ std::unique_ptr<api::WifiHotspotSocket> WifiHotspotMedium::ConnectToService(
platform::config_package_nearby::nearby_platform_feature::
kWifiHotspotConnectionTimeoutMillis);
LOG(INFO) << "maximum connection retries="
<< wifi_hotspot_max_connection_retries
<< ", connection interval=" << wifi_hotspot_retry_interval_millis
<< "ms, connection timeout="
<< wifi_hotspot_client_socket_connect_timeout_millis << "ms";
VLOG(1) << "maximum connection retries="
<< wifi_hotspot_max_connection_retries
<< ", connection interval=" << wifi_hotspot_retry_interval_millis
<< "ms, connection timeout="
<< wifi_hotspot_client_socket_connect_timeout_millis << "ms";
if (NearbyFlags::GetInstance().GetBoolFlag(
nearby::platform::config_package_nearby::nearby_platform_feature::
@@ -273,7 +273,7 @@ WifiHotspotMedium::ListenForService(int port) {
bool WifiHotspotMedium::StartWifiHotspot(
HotspotCredentials* hotspot_credentials) {
absl::MutexLock lock(&mutex_);
LOG(INFO) << __func__ << ": Start to create WiFi Hotspot.";
VLOG(1) << __func__ << ": Start to create WiFi Hotspot.";
if (IsBeaconing()) {
LOG(WARNING) << "Cannot create WiFi Hotspot again when it is running.";
@@ -391,11 +391,11 @@ fire_and_forget WifiHotspotMedium::OnStatusChanged(
LOG(INFO) << "WiFi SoftAP SSID: "
<< winrt::to_string(
publisher_.Advertisement().LegacySettings().Ssid());
LOG(INFO) << "WiFi SoftAP PW: "
<< winrt::to_string(publisher_.Advertisement()
.LegacySettings()
.Passphrase()
.Password());
VLOG(1) << "WiFi SoftAP PW: "
<< winrt::to_string(publisher_.Advertisement()
.LegacySettings()
.Passphrase()
.Password());
}
return winrt::fire_and_forget();
} else if (event.Status() ==
@@ -544,9 +544,9 @@ bool WifiHotspotMedium::ConnectWifiHotspot(
NearbyFlags::GetInstance().GetInt64Flag(
platform::config_package_nearby::nearby_platform_feature::
kWifiHotspotCheckIpIntervalMillis);
LOG(INFO) << "maximum IP check retries=" << ip_address_max_retries
<< ", IP check interval=" << ip_address_retry_interval_millis
<< "ms";
VLOG(1) << "maximum IP check retries=" << ip_address_max_retries
<< ", IP check interval=" << ip_address_retry_interval_millis
<< "ms";
for (int i = 0; i < ip_address_max_retries; i++) {
LOG(INFO) << "Check IP address at attempt " << i;
std::vector<std::string> ip_addresses = GetWifiIpv4Addresses();
@@ -81,7 +81,7 @@ WifiHotspotNative::WifiHotspotNative() {
return;
}
LOG(INFO) << "WifiHotspotNative created successfully.";
VLOG(1) << "WifiHotspotNative created successfully.";
}
WifiHotspotNative::~WifiHotspotNative() {
@@ -90,7 +90,7 @@ WifiHotspotNative::~WifiHotspotNative() {
wifi_ = nullptr;
}
LOG(INFO) << "WifiHotspotNative destroyed successfully.";
VLOG(1) << "WifiHotspotNative destroyed successfully.";
}
bool WifiHotspotNative::ConnectToWifiNetwork(
@@ -71,11 +71,7 @@ std::string WifiHotspotServerSocket::GetIPAddress() const {
}
}
std::string hotspot_ip_address = GetHotspotIpAddress();
LOG(INFO) << __func__
<< ": Return hotspot IP address: " << hotspot_ip_address;
return hotspot_ip_address;
return GetHotspotIpAddress();
}
}
@@ -112,7 +108,7 @@ std::unique_ptr<api::WifiHotspotSocket> WifiHotspotServerSocket::Accept() {
return std::make_unique<WifiHotspotSocket>(std::move(client_socket));
} else {
absl::MutexLock lock(&mutex_);
LOG(INFO) << __func__ << ": Accept is called.";
VLOG(1) << __func__ << ": Accept is called.";
if (NearbyFlags::GetInstance().GetBoolFlag(
platform::config_package_nearby::nearby_platform_feature::
@@ -160,10 +156,8 @@ Exception WifiHotspotServerSocket::Close() {
if (close_notifier_ != nullptr) {
close_notifier_();
}
LOG(INFO) << __func__ << ": Close completed successfully.";
} else {
LOG(INFO) << __func__ << ": Close is called.";
VLOG(1) << __func__ << ": Close is called.";
if (closed_) {
return {Exception::kSuccess};
@@ -352,7 +346,7 @@ bool WifiHotspotServerSocket::SetupServerSocketWinSock() {
SocketErrorNotice("Bind");
return false;
}
LOG(INFO) << "Bind socket successful";
VLOG(1) << "Bind socket successful";
int size = sizeof(serv_addr);
memset(&serv_addr, 0, size);
@@ -362,7 +356,6 @@ bool WifiHotspotServerSocket::SetupServerSocketWinSock() {
return false;
}
port_ = ntohs(serv_addr.sin_port);
LOG(INFO) << "Hotspot Server bound to port: " << port_;
socket_events_[kSocketEventListen] = WSACreateEvent();
if (socket_events_[kSocketEventListen] == WSA_INVALID_EVENT) {
@@ -389,7 +382,7 @@ bool WifiHotspotServerSocket::SetupServerSocketWinSock() {
return false;
}
LOG(INFO) << "Hotspot Server Socket " << listen_socket_
<< " started to listen.";
<< " started to listen on port: " << port_;
submittable_executor_.Execute([this]() {
DWORD index;
@@ -398,8 +391,8 @@ bool WifiHotspotServerSocket::SetupServerSocketWinSock() {
index = WSAWaitForMultipleEvents(kSocketEventsCount, socket_events_, FALSE,
WSA_INFINITE, FALSE);
LOG(INFO) << "Hotspot Server Socket " << listen_socket_
<< " received event index: " << index;
VLOG(1) << "Hotspot Server Socket " << listen_socket_
<< " received event index: " << index;
if (index == WSA_WAIT_TIMEOUT || index == WSA_WAIT_FAILED) {
LOG(INFO) << "Hotspot Server Socket timout or failed ";
return false;
@@ -424,7 +417,7 @@ bool WifiHotspotServerSocket::SetupServerSocketWinSock() {
}
if (network_events.lNetworkEvents & FD_ACCEPT) {
client_socket_ = accept(listen_socket_, nullptr, nullptr);
LOG(INFO) << "Reveived FD_ACCEPT event.";
VLOG(1) << "Reveived FD_ACCEPT event.";
if (client_socket_ == INVALID_SOCKET) {
return false;
@@ -461,9 +454,8 @@ bool WifiHotspotServerSocket::listen() {
NearbyFlags::GetInstance().GetInt64Flag(
platform::config_package_nearby::nearby_platform_feature::
kWifiHotspotCheckIpIntervalMillis);
LOG(INFO) << "maximum IP check retries=" << ip_address_max_retries
<< ", IP check interval=" << ip_address_retry_interval_millis
<< "ms";
VLOG(1) << "maximum IP check retries=" << ip_address_max_retries
<< ", IP check interval=" << ip_address_retry_interval_millis << "ms";
for (int i = 0; i < ip_address_max_retries; i++) {
hotspot_ipaddr_ = GetHotspotIpAddress();
if (hotspot_ipaddr_.empty()) {
@@ -195,7 +195,7 @@ std::optional<std::string> WifiLanMdns::GetComputerName() {
void WifiLanMdns::DnsServiceRegisterComplete(DWORD Status, PVOID pQueryContext,
PDNS_SERVICE_INSTANCE pInstance) {
LOG(INFO) << "DnsServiceRegisterComplete: " << Status;
VLOG(1) << "DnsServiceRegisterComplete: " << Status;
WifiLanMdns* mdns = static_cast<WifiLanMdns*>(pQueryContext);
mdns->NotifyStatusUpdated(Status);
}
@@ -86,10 +86,10 @@ bool WifiLanMedium::StartAdvertising(const NsdServiceInfo& nsd_service_info) {
if ((server_socket.second->GetIPAddress() ==
nsd_service_info.GetIPAddress()) &&
(server_socket.second->GetPort() == nsd_service_info.GetPort())) {
LOG(INFO) << "Found the server socket." << " IP: "
<< ipaddr_4bytes_to_dotdecimal_string(
nsd_service_info.GetIPAddress())
<< "; port: " << nsd_service_info.GetPort();
VLOG(1) << "Found the server socket." << " IP: "
<< ipaddr_4bytes_to_dotdecimal_string(
nsd_service_info.GetIPAddress())
<< "; port: " << nsd_service_info.GetPort();
server_socket_ptr = server_socket.second;
socket_found = true;
break;
@@ -217,7 +217,6 @@ bool WifiLanMedium::StopAdvertising(const NsdServiceInfo& nsd_service_info) {
bool result = wifi_lan_mdns_.StopMdnsService();
if (result) {
LOG(INFO) << "succeeded to stop mDNS advertising.";
medium_status_ &= (~kMediumStatusAdvertising);
return true;
}
@@ -46,11 +46,11 @@ WifiLanSocket::WifiLanSocket(StreamSocket socket) {
nearby::platform::config_package_nearby::nearby_platform_feature::
kEnableBlockingSocket);
stream_soket_ = socket;
LOG(INFO) << "Socket send buffer size: "
<< socket.Control().OutboundBufferSizeInBytes();
VLOG(1) << "Socket send buffer size: "
<< socket.Control().OutboundBufferSizeInBytes();
socket.Control().OutboundBufferSizeInBytes(4 * 1024 * 1024);
LOG(INFO) << "Updated send buffer size to: "
<< socket.Control().OutboundBufferSizeInBytes();
VLOG(1) << "Updated send buffer size to: "
<< socket.Control().OutboundBufferSizeInBytes();
input_stream_ = SocketInputStream(socket.InputStream());
output_stream_ = SocketOutputStream(socket.OutputStream());
}