Using spdlog for logs
This commit is contained in:
parent
9515077e1e
commit
33ba0995fd
@ -1,8 +1,8 @@
|
|||||||
#include "app_win_2_back.hpp"
|
#include "app_win_2_back.hpp"
|
||||||
#include "hello_world.hpp"
|
#include "hello_world.hpp"
|
||||||
#include <iostream>
|
|
||||||
#include <glibmm/miscutils.h>
|
#include <glibmm/miscutils.h>
|
||||||
#include <gtkmm/switch.h>
|
#include <gtkmm/switch.h>
|
||||||
|
#include <spdlog/spdlog.h>
|
||||||
|
|
||||||
namespace gui_to_app {
|
namespace gui_to_app {
|
||||||
AppWin2Back::AppWin2Back() : Gtk::Application("org.billy_adventures.character_sheet", Flags::HANDLES_OPEN) {
|
AppWin2Back::AppWin2Back() : Gtk::Application("org.billy_adventures.character_sheet", Flags::HANDLES_OPEN) {
|
||||||
@ -16,12 +16,12 @@ namespace gui_to_app {
|
|||||||
const auto builder = Gtk::Builder::create_from_file("menu_bar.ui");
|
const auto builder = Gtk::Builder::create_from_file("menu_bar.ui");
|
||||||
return builder->get_object<Gio::Menu>("menu");
|
return builder->get_object<Gio::Menu>("menu");
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
std::cerr << e.what() << '\n';
|
spdlog::error("Error occurred while loader menu bar: {}", e.what());
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}();
|
}();
|
||||||
if (!menu_bar) {
|
if (!menu_bar) {
|
||||||
std::cerr << "Error occured while loading menu bar's.\n";
|
spdlog::error("Error occured while loading menu bar's.");
|
||||||
} else {
|
} else {
|
||||||
set_menubar(menu_bar);
|
set_menubar(menu_bar);
|
||||||
add_action("quit", sigc::mem_fun(*this, &AppWin2Back::on_quit));
|
add_action("quit", sigc::mem_fun(*this, &AppWin2Back::on_quit));
|
||||||
@ -40,13 +40,13 @@ namespace gui_to_app {
|
|||||||
try {
|
try {
|
||||||
return Gtk::Builder::create_from_file("window_ui.ui");
|
return Gtk::Builder::create_from_file("window_ui.ui");
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
std::cerr << e.what() << std::endl;
|
spdlog::critical("Error occurred while loading Window's UI: {}", e.what());
|
||||||
quit();
|
quit();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}();
|
}();
|
||||||
if (!app_builder) {
|
if (!app_builder) {
|
||||||
std::cerr << "Error while loading UI.\n";
|
spdlog::critical("Error while loading UI");
|
||||||
quit();
|
quit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -56,6 +56,7 @@ namespace gui_to_app {
|
|||||||
main_window->set_show_menubar(true);
|
main_window->set_show_menubar(true);
|
||||||
main_window->set_visible(true);
|
main_window->set_visible(true);
|
||||||
} else {
|
} else {
|
||||||
|
spdlog::critical("Error while getting window from builder");
|
||||||
on_quit();
|
on_quit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -97,9 +98,9 @@ namespace gui_to_app {
|
|||||||
return test_result;
|
return test_result;
|
||||||
}();
|
}();
|
||||||
if (!test_result.empty()) {
|
if (!test_result.empty()) {
|
||||||
std::cerr << "Error occurred, at least one switch is not available:\n";
|
spdlog::critical("Error occurred, at least one switch is not available. See logs below");
|
||||||
for (const auto result: test_result) {
|
for (const auto result: test_result) {
|
||||||
std::cerr << result << '\n';
|
spdlog::critical(result);
|
||||||
}
|
}
|
||||||
on_quit();
|
on_quit();
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user