mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
Adding logging
This commit is contained in:
parent
b31a64ad00
commit
2c1a3d0430
@ -1,6 +1,7 @@
|
||||
#include "modules/network.hpp"
|
||||
#include <sys/eventfd.h>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
namespace {
|
||||
|
||||
@ -12,6 +13,7 @@ namespace {
|
||||
std::ifstream netstat(NETSTAT_FILE);
|
||||
std::optional<unsigned long long> read_netstat(std::string_view category, std::string_view key) {
|
||||
if (!netstat) {
|
||||
std::cerr << "Failed to open netstat file " << NETSTAT_FILE << '\n' << std::flush;
|
||||
return {};
|
||||
}
|
||||
netstat.seekg(std::ios_base::beg);
|
||||
@ -26,6 +28,7 @@ namespace {
|
||||
std::string read;
|
||||
while (std::getline(netstat, read) && !starts_with(read, category));
|
||||
if (!starts_with(read, category)) {
|
||||
std::cerr << "Category '" << category << "' not found in netstat file " << NETSTAT_FILE << '\n' << std::flush;
|
||||
return {};
|
||||
}
|
||||
|
||||
@ -49,6 +52,7 @@ namespace {
|
||||
}
|
||||
|
||||
if (r_it == read.end() && k_it != key.end()) {
|
||||
std::cerr << "Key '" << key << "' not found in category '" << category << "' of netstat file " << NETSTAT_FILE << '\n' << std::flush;
|
||||
return {};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user