diff options
| author | Felix Morgner <felix.morgner@gmail.com> | 2018-11-30 19:13:51 +0100 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@gmail.com> | 2018-11-30 19:13:51 +0100 |
| commit | 4ded35e5f876d5e8daab47e429450f9bf5e32666 (patch) | |
| tree | cfe08bbd6827a2cfa3b6cdeed03e537de2c951c5 /src/wandad.cpp | |
| parent | 85947e3caa26f905538186a32bb67e16d59d1260 (diff) | |
| download | wanda-4ded35e5f876d5e8daab47e429450f9bf5e32666.tar.xz wanda-4ded35e5f876d5e8daab47e429450f9bf5e32666.zip | |
wandad: begin implementing better logging
Diffstat (limited to 'src/wandad.cpp')
| -rw-r--r-- | src/wandad.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/wandad.cpp b/src/wandad.cpp index beb9040..b7bc0fe 100644 --- a/src/wandad.cpp +++ b/src/wandad.cpp @@ -8,6 +8,9 @@ #include <boost/asio.hpp> +#include <spdlog/spdlog.h> +#include <spdlog/sinks/stdout_color_sinks.h> + #include <csignal> #include <iostream> #include <set> @@ -36,20 +39,22 @@ int main() { using namespace wanda::std_ext; - with(wanda::scan({"/usr/share/backgrounds"}, image_filter), [](auto const &list) { + auto log = spdlog::stdout_color_mt("wandad"); + log->info("wanda is starting up"); + + with(wanda::scan({"/usr/share/backgrounds"}, image_filter), [&](auto const &list) { auto wallpaper = wanda::random_pick(list); wanda::set_wallpaper(wallpaper); auto service = boost::asio::io_service{}; auto socket_path = wanda::xdg_path_for(wanda::xdg_directory::runtime_dir, wanda::environment{}) / ".wanda_interface"; - std::clog << "[wandad::main] Initializing control interface on socket '" << socket_path.native() << "'\n"; - auto interface = wanda::make_interface(service, socket_path); + log->info("starting control interface on '{}'", socket_path.native()); + auto interface = wanda::make_interface(service, socket_path, log); if(!interface) { - std::cerr << "[wandad::main] Failed to initialize control interface on socket '" << socket_path.native() << "'\n" - << "[wandad::main] File already existed. Is 'wandad' running already?\n"; + log->error("failed to start control interface"); return; } @@ -68,5 +73,5 @@ int main() }); service.run(); - }) || [] { std::cerr << "Directory does not exist\n"; }; + }) || [&] { log->error("wallpaper directory does not exist"); }; } |
