find_package(PkgConfig)
pkg_check_modules(DEPS REQUIRED IMPORTED_TARGET
- gio-2.0
- libsmack
+ gio-2.0
+ libsmack
+ dlog
)
set(
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE. */
+#undef LOG_TAG
+#define LOG_TAG "SESSIOND"
+#include <dlog.h>
+
#include <grp.h>
#include <pwd.h>
#include <sys/smack.h>
return fs::exists(subsession_path);
}
catch (std::exception const &ex) {
- std::cerr << "Exception " << ex.what() << std::endl
- << "while executing subsession_exists function [session_uid=" << session_uid
- << " subsession_id=" << subsession_id << "]" << std::endl;
+ LOGE("Exception %s\nwhile executing subsession_exists function [session_uid=%d subsession_id=%s]", ex.what(), session_uid, subsession_id.data());
return false;
}
}
catch (std::system_error const &ex) {
- std::cerr << "Logic exception " << ex.what() << std::endl
- << "while copying user subsession data [session_uid=" << session_uid
- << " subsession_id=" << subsession_id << "]" << std::endl;
+ LOGE("Logic exception %s\nwhile copying user subsession data [session_uid=%d subsession_id=%s]", ex.what(), session_uid, subsession_id.data());
throw;
}
catch (std::exception const &ex) {
- std::cerr << "Exception " << ex.what() << std::endl
- << "while copying user subsession data [session_uid=" << session_uid
- << " subsession_id=" << subsession_id << "]" << std::endl;
+ LOGE("Exception %s\nwhile copying user subsession data [session_uid=%d subsession_id=%s]", ex.what(), session_uid, subsession_id.data());
throw std::runtime_error("Couldn't add user subsession data");
}
}
fs::remove_all(subsession_path);
}
catch (std::system_error const &ex) {
- std::cerr << "Logic exception " << ex.what() << std::endl
- << "while removing user subsession data [session_uid=" << session_uid
- << " subsession_id=" << subsession_id << "]" << std::endl;
+ LOGE("Logic exception %s\nwhile removing user subsession data [session_uid=%d subsession_id=%s]", ex.what(), session_uid, subsession_id.data());
throw;
}
catch (std::exception const &ex) {
- std::cerr << "Exception " << ex.what() << std::endl
- << "while removing user subsession data [session_uid=" << session_uid
- << " subsession_id=" << subsession_id << "]" << std::endl;
+ LOGE("Exception %s\nwhile removing user subsession data [session_uid=%d subsession_id=%s]", ex.what(), session_uid, subsession_id.data());
throw std::runtime_error("Couldn't remove user subsession data");
}
}
} catch (std::runtime_error &ex) {
return {};
} catch (std::exception const &ex) {
- std::cerr << "Exception " << ex.what() << std::endl
- << "while enumerating user subsessions [session_uid="
- << session_uid << "]" << std::endl;
+ LOGE("Exception %s\nwhile enumerating user subsessions [session_uid=%d]", ex.what(), session_uid);
throw std::runtime_error("Couldn't enumerate user subsessions");
}
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE. */
+#undef LOG_TAG
+#define LOG_TAG "SESSIOND"
+#include <dlog.h>
+
#include <algorithm>
-#include <iostream>
#include <unordered_map>
#include <gio/gio.h>
{
inner = g_bus_own_name_on_connection(connection, name.data(), G_BUS_NAME_OWNER_FLAGS_NONE,
on_name_acquired, on_name_lost, user_data, nullptr);
- std::cout << "Acquiring " << name << std::endl;
+ LOGD("Acquiring %s", name.data());
}
~owner_id()
void on_name_acquired()
{
- std::cout << "Bus name acquired" << std::endl;
+ LOGD("Bus name acquired");
}
void on_name_lost()
});
if (to_call == methods.end())
throw std::runtime_error(std::string("Unknown method ") + method_name + " called");
- std::cout << "Handling " << method_name << " call from " << sender << std::endl;
+ LOGD("Handling %s call from %s", method_name, sender);
(self->*(to_call->second))(invocation, std::string_view(sender), parameters);
} catch (const std::invalid_argument &ex) {
g_dbus_method_invocation_return_dbus_error(invocation,
}
static void log_exception(const std::exception &ex, std::string_view sender, std::string_view method_name)
{
- // TODO: use dlog instead
- std::cerr << "Exception " << ex.what() << std::endl <<
- "while handling " << method_name << " call from " << sender << std::endl;
+ LOGE("Exception %s\nwhile handling %s call from %s", ex.what(), method_name.data(), sender.data());
}
constexpr static GDBusInterfaceVTable table = {
int main() try {
sessiond_context().run();
} catch (const std::exception &ex) {
- std::cerr << "Exception " << ex.what() << " caught in top scope! Bailing out..." << std::endl;
+ LOGE("Exception %s caught in top scope! Bailing out...", ex.what());
return EXIT_FAILURE;
}
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE. */
+#undef LOG_TAG
+#define LOG_TAG "SESSIOND"
+#include <dlog.h>
+
#include <algorithm>
#include <exception>
#include <iostream>
finalize_if_empty(waiting_for.first, waiting_for.second.second);
}
} catch (const std::exception &ex) {
- std::cerr << "Exception " << ex.what() << "\n" <<
- "while finalizing the wait manager\n";
+ LOGE("Exception %s\nwhile finalizing the wait manager", ex.what());
}
for (auto &timeout : timeouts)
auto self = static_cast<wait_manager *>(user_data);
self->on_client_disappeared(std::string(name));
} catch (const std::exception &ex) {
- std::cerr << "Exception " << ex.what() << "\n" <<
- "while handling " << name << " disappearing\n";
+ LOGE("Exception %s\nwhile handling %s disappearing", ex.what(), name);
}
struct timeout_data {
data->active = false;
return G_SOURCE_REMOVE;
} catch (const std::exception &ex) {
- std::cerr << "Exception " << ex.what() << "\n" <<
- "while timeout\n";
+ LOGE("Exception %s\nwhile timeout", ex.what());
return G_SOURCE_REMOVE;
}