Merge pull request #332 from Organic-Code/enhancement/spdlog

Adding spdlog
This commit is contained in:
Alex
2019-05-20 12:07:58 +02:00
committed by GitHub
21 changed files with 89 additions and 69 deletions

View File

@ -1,5 +1,6 @@
#include "modules/sni/host.hpp"
#include <iostream>
#include <spdlog/spdlog.h>
#include <fmt/ostream.h>
namespace waybar::modules::SNI {
@ -63,14 +64,14 @@ void Host::proxyReady(GObject* src, GAsyncResult* res, gpointer data) {
GError* error = nullptr;
SnWatcher* watcher = sn_watcher_proxy_new_finish(res, &error);
if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
std::cerr << error->message << std::endl;
spdlog::error("Host: {}", error->message);
g_error_free(error);
return;
}
auto host = static_cast<SNI::Host*>(data);
host->watcher_ = watcher;
if (error != nullptr) {
std::cerr << error->message << std::endl;
spdlog::error("Host: {}", error->message);
g_error_free(error);
return;
}
@ -82,13 +83,13 @@ void Host::registerHost(GObject* src, GAsyncResult* res, gpointer data) {
GError* error = nullptr;
sn_watcher_call_register_host_finish(SN_WATCHER(src), res, &error);
if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
std::cerr << error->message << std::endl;
spdlog::error("Host: {}", error->message);
g_error_free(error);
return;
}
auto host = static_cast<SNI::Host*>(data);
if (error != nullptr) {
std::cerr << error->message << std::endl;
spdlog::error("Host: {}", error->message);
g_error_free(error);
return;
}
@ -139,4 +140,4 @@ void Host::addRegisteredItem(std::string service) {
}
}
} // namespace waybar::modules::SNI
} // namespace waybar::modules::SNI

View File

@ -1,6 +1,6 @@
#include "modules/sni/item.hpp"
#include <glibmm/main.h>
#include <iostream>
#include <spdlog/spdlog.h>
namespace waybar::modules::SNI {
@ -47,8 +47,7 @@ void Item::proxyReady(Glib::RefPtr<Gio::AsyncResult>& result) {
this->proxy_->signal_signal().connect(sigc::mem_fun(*this, &Item::onSignal));
if (this->id.empty() || this->category.empty() || this->status.empty()) {
std::cerr << "Invalid Status Notifier Item: " + this->bus_name + "," + this->object_path
<< std::endl;
spdlog::error("Invalid Status Notifier Item: {}, {}", bus_name, object_path);
return;
}
this->updateImage();
@ -235,7 +234,7 @@ void Item::updateImage() {
image.set(getIconByName(icon_name, icon_size));
}
} catch (Glib::Error& e) {
std::cerr << "Exception: " << e.what() << std::endl;
spdlog::error("Item '{}': {}", id, static_cast<std::string>(e.what()));
}
} else if (icon_pixmap) {
// An icon extracted may be the wrong size for the tray
@ -321,4 +320,4 @@ bool Item::handleClick(GdkEventButton* const& ev) {
return false;
}
} // namespace waybar::modules::SNI
} // namespace waybar::modules::SNI

View File

@ -1,5 +1,4 @@
#include "modules/sni/tray.hpp"
#include <iostream>
namespace waybar::modules::SNI {
@ -40,4 +39,4 @@ auto Tray::update() -> void {
Tray::operator Gtk::Widget&() { return box_; }
}
}

View File

@ -1,6 +1,5 @@
#include "modules/sni/watcher.hpp"
#include <iostream>
#include <spdlog/spdlog.h>
using namespace waybar::modules::SNI;
@ -35,7 +34,7 @@ void Watcher::busAcquired(const Glib::RefPtr<Gio::DBus::Connection>& conn, Glib:
if (error != nullptr) {
// Don't print an error when a watcher is already present
if (error->code != 2) {
std::cerr << error->message << std::endl;
spdlog::error("Watcher {}: {}", watcher_id_, error->message);
}
g_error_free(error);
return;
@ -194,4 +193,4 @@ void Watcher::updateRegisteredItems(SnWatcher* obj) {
sn_watcher_set_registered_items(obj, items);
g_variant_unref(variant);
g_free(items);
}
}