Removed Debug logs from user-view
This commit is contained in:
@@ -325,41 +325,41 @@ NetworkManager& NetworkManager::operator=(NetworkManager&&) noexcept = default;
|
||||
// ─── Lifecycle ─────────────────────────────────────────────────────────
|
||||
|
||||
bool NetworkManager::initialize() {
|
||||
log("Initializing NetworkManager connection...");
|
||||
logDebug("Initializing NetworkManager connection...");
|
||||
|
||||
#ifdef __linux__
|
||||
int r = sd_bus_open_system(&impl_->bus);
|
||||
if (r < 0) {
|
||||
log("Failed to open system bus: " + std::string(strerror(-r)));
|
||||
logWarning("Failed to open system bus: " + std::string(strerror(-r)));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if NM is running
|
||||
uint32_t state = 0;
|
||||
if (!impl_->getProperty(NM_SERVICE, NM_PATH, NM_SERVICE, "State", "u", &state)) {
|
||||
log("Failed to get NM state - is NetworkManager running?");
|
||||
logWarning("Failed to get NM state - is NetworkManager running?");
|
||||
return false;
|
||||
}
|
||||
|
||||
log("NetworkManager state: " + std::to_string(state));
|
||||
logDebug("NetworkManager state: " + std::to_string(state));
|
||||
|
||||
// Find WiFi device
|
||||
impl_->device = WifiDevice::findFirstDevice();
|
||||
if (!impl_->device) {
|
||||
log("No WiFi device found");
|
||||
logDebug("No WiFi device found");
|
||||
return false;
|
||||
}
|
||||
|
||||
log("Found WiFi device: " + impl_->device->getInterfaceName());
|
||||
logDebug("Found WiFi device: " + impl_->device->getInterfaceName());
|
||||
return true;
|
||||
#else
|
||||
log("NetworkManager not available on this platform");
|
||||
logDebug("NetworkManager not available on this platform");
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
void NetworkManager::shutdown() {
|
||||
log("Shutting down NetworkManager connection...");
|
||||
logDebug("Shutting down NetworkManager connection...");
|
||||
impl_->device.reset();
|
||||
|
||||
#ifdef __linux__
|
||||
@@ -374,14 +374,14 @@ void NetworkManager::shutdown() {
|
||||
|
||||
bool NetworkManager::requestScan() {
|
||||
if (!impl_->device) {
|
||||
log("No WiFi device available");
|
||||
logDebug("No WiFi device available");
|
||||
return false;
|
||||
}
|
||||
|
||||
log("Requesting WiFi scan...");
|
||||
logDebug("Requesting WiFi scan...");
|
||||
const bool ok = impl_->device->requestScan();
|
||||
if (!ok) {
|
||||
log("RequestScan failed; the network list may stay empty until it succeeds");
|
||||
logWarning("RequestScan failed; the network list may stay empty until it succeeds");
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
@@ -446,7 +446,7 @@ ConnectResult NetworkManager::connect(
|
||||
const std::string& password,
|
||||
std::chrono::seconds timeout
|
||||
) {
|
||||
log("Connecting to: " + ssid);
|
||||
logDebug("Connecting to: " + ssid);
|
||||
notifyState(ConnectionState::Preparing, "Preparing connection to " + ssid);
|
||||
|
||||
if (!impl_->device) {
|
||||
@@ -517,7 +517,7 @@ bool NetworkManager::disconnect() {
|
||||
return false;
|
||||
}
|
||||
|
||||
log("Disconnecting...");
|
||||
logDebug("Disconnecting...");
|
||||
|
||||
#ifdef __linux__
|
||||
// Get active connection
|
||||
@@ -632,7 +632,7 @@ bool NetworkManager::forgetNetwork(const std::string& ssid) {
|
||||
|
||||
if (r >= 0) {
|
||||
found = true;
|
||||
log("Deleted connection profile: " + std::string(conn_path));
|
||||
logDebug("Deleted connection profile: " + std::string(conn_path));
|
||||
}
|
||||
sd_bus_error_free(&del_error);
|
||||
}
|
||||
@@ -775,6 +775,20 @@ void NetworkManager::log(const std::string& message) {
|
||||
radiantwave::logger::Logger::instance().info("WiFi", message);
|
||||
}
|
||||
|
||||
void NetworkManager::logDebug(const std::string& message) {
|
||||
if (impl_->log_callback) {
|
||||
impl_->log_callback("[NM] " + message);
|
||||
}
|
||||
radiantwave::logger::Logger::instance().debug("WiFi", message);
|
||||
}
|
||||
|
||||
void NetworkManager::logWarning(const std::string& message) {
|
||||
if (impl_->log_callback) {
|
||||
impl_->log_callback("[NM] " + message);
|
||||
}
|
||||
radiantwave::logger::Logger::instance().warning("WiFi", message);
|
||||
}
|
||||
|
||||
void NetworkManager::notifyState(ConnectionState state, const std::string& message) {
|
||||
if (state != impl_->last_notified_state && impl_->state_callback) {
|
||||
impl_->last_notified_state = state;
|
||||
@@ -797,7 +811,7 @@ bool NetworkManager::waitForDeviceState(uint32_t target_state, std::chrono::seco
|
||||
}
|
||||
|
||||
if (current_state == nm_device_state::Failed) {
|
||||
log("Device state changed to Failed");
|
||||
logWarning("Device state changed to Failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -808,7 +822,7 @@ bool NetworkManager::waitForDeviceState(uint32_t target_state, std::chrono::seco
|
||||
}
|
||||
|
||||
void NetworkManager::deleteStaleProfiles(const std::string& ssid) {
|
||||
log("Deleting stale profiles for: " + ssid);
|
||||
logDebug("Deleting stale profiles for: " + ssid);
|
||||
forgetNetwork(ssid);
|
||||
}
|
||||
|
||||
@@ -902,11 +916,11 @@ void NetworkManager::refreshDnsResolver() const {
|
||||
}
|
||||
|
||||
bool NetworkManager::waitForFullConnectivity(std::chrono::seconds timeout) {
|
||||
log("Waiting for full connectivity...");
|
||||
logDebug("Waiting for full connectivity...");
|
||||
|
||||
// Wait for device to be activated
|
||||
if (!waitForDeviceState(nm_device_state::Activated, timeout)) {
|
||||
log("Device did not reach Activated state");
|
||||
logWarning("Device did not reach Activated state");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -927,7 +941,7 @@ bool NetworkManager::waitForFullConnectivity(std::chrono::seconds timeout) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
}
|
||||
|
||||
log("No internet connectivity after timeout");
|
||||
logWarning("No internet connectivity after timeout");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,9 @@ public:
|
||||
|
||||
private:
|
||||
// Internal helpers
|
||||
void log(const std::string& message);
|
||||
void log(const std::string& message); // Info level
|
||||
void logDebug(const std::string& message); // Debug level
|
||||
void logWarning(const std::string& message); // Warning level
|
||||
void notifyState(ConnectionState state, const std::string& message);
|
||||
|
||||
// Wait for device state
|
||||
|
||||
Reference in New Issue
Block a user