mirror of
https://github.com/swaywm/sway.git
synced 2026-04-12 08:21:23 -04:00
Replace wlr_log with sway_log
This commit mostly duplicates the wlr_log functions, although with a sway_* prefix. (This is very similar to PR #2009.) However, the logging function no longer needs to be replaceable, so sway_log_init's second argument is used to set the exit callback for sway_abort. wlr_log_init is still invoked in sway/main.c This commit makes it easier to remove the wlroots dependency for the helper programs swaymsg, swaybg, swaybar, and swaynag.
This commit is contained in:
parent
5c834d36e1
commit
1211a81aad
108 changed files with 613 additions and 504 deletions
|
|
@ -21,7 +21,7 @@ static int cmp_sni_id(const void *item, const void *cmp_to) {
|
|||
static void add_sni(struct swaybar_tray *tray, char *id) {
|
||||
int idx = list_seq_find(tray->items, cmp_sni_id, id);
|
||||
if (idx == -1) {
|
||||
wlr_log(WLR_INFO, "Registering Status Notifier Item '%s'", id);
|
||||
sway_log(SWAY_INFO, "Registering Status Notifier Item '%s'", id);
|
||||
struct swaybar_sni *sni = create_sni(id, tray);
|
||||
if (sni) {
|
||||
list_add(tray->items, sni);
|
||||
|
|
@ -34,7 +34,7 @@ static int handle_sni_registered(sd_bus_message *msg, void *data,
|
|||
char *id;
|
||||
int ret = sd_bus_message_read(msg, "s", &id);
|
||||
if (ret < 0) {
|
||||
wlr_log(WLR_ERROR, "Failed to parse register SNI message: %s", strerror(-ret));
|
||||
sway_log(SWAY_ERROR, "Failed to parse register SNI message: %s", strerror(-ret));
|
||||
}
|
||||
|
||||
struct swaybar_tray *tray = data;
|
||||
|
|
@ -48,13 +48,13 @@ static int handle_sni_unregistered(sd_bus_message *msg, void *data,
|
|||
char *id;
|
||||
int ret = sd_bus_message_read(msg, "s", &id);
|
||||
if (ret < 0) {
|
||||
wlr_log(WLR_ERROR, "Failed to parse unregister SNI message: %s", strerror(-ret));
|
||||
sway_log(SWAY_ERROR, "Failed to parse unregister SNI message: %s", strerror(-ret));
|
||||
}
|
||||
|
||||
struct swaybar_tray *tray = data;
|
||||
int idx = list_seq_find(tray->items, cmp_sni_id, id);
|
||||
if (idx != -1) {
|
||||
wlr_log(WLR_INFO, "Unregistering Status Notifier Item '%s'", id);
|
||||
sway_log(SWAY_INFO, "Unregistering Status Notifier Item '%s'", id);
|
||||
destroy_sni(tray->items->items[idx]);
|
||||
list_del(tray->items, idx);
|
||||
set_bar_dirty(tray->bar);
|
||||
|
|
@ -66,20 +66,20 @@ static int get_registered_snis_callback(sd_bus_message *msg, void *data,
|
|||
sd_bus_error *error) {
|
||||
if (sd_bus_message_is_method_error(msg, NULL)) {
|
||||
sd_bus_error err = *sd_bus_message_get_error(msg);
|
||||
wlr_log(WLR_ERROR, "Failed to get registered SNIs: %s", err.message);
|
||||
sway_log(SWAY_ERROR, "Failed to get registered SNIs: %s", err.message);
|
||||
return -sd_bus_error_get_errno(&err);
|
||||
}
|
||||
|
||||
int ret = sd_bus_message_enter_container(msg, 'v', NULL);
|
||||
if (ret < 0) {
|
||||
wlr_log(WLR_ERROR, "Failed to read registered SNIs: %s", strerror(-ret));
|
||||
sway_log(SWAY_ERROR, "Failed to read registered SNIs: %s", strerror(-ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
char **ids;
|
||||
ret = sd_bus_message_read_strv(msg, &ids);
|
||||
if (ret < 0) {
|
||||
wlr_log(WLR_ERROR, "Failed to read registered SNIs: %s", strerror(-ret));
|
||||
sway_log(SWAY_ERROR, "Failed to read registered SNIs: %s", strerror(-ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -99,7 +99,7 @@ static bool register_to_watcher(struct swaybar_host *host) {
|
|||
host->watcher_interface, watcher_path, host->watcher_interface,
|
||||
"RegisterStatusNotifierHost", NULL, NULL, "s", host->service);
|
||||
if (ret < 0) {
|
||||
wlr_log(WLR_ERROR, "Failed to send register call: %s", strerror(-ret));
|
||||
sway_log(SWAY_ERROR, "Failed to send register call: %s", strerror(-ret));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -109,7 +109,7 @@ static bool register_to_watcher(struct swaybar_host *host) {
|
|||
get_registered_snis_callback, host->tray, "ss",
|
||||
host->watcher_interface, "RegisteredStatusNotifierItems");
|
||||
if (ret < 0) {
|
||||
wlr_log(WLR_ERROR, "Failed to get registered SNIs: %s", strerror(-ret));
|
||||
sway_log(SWAY_ERROR, "Failed to get registered SNIs: %s", strerror(-ret));
|
||||
}
|
||||
|
||||
return ret >= 0;
|
||||
|
|
@ -120,7 +120,7 @@ static int handle_new_watcher(sd_bus_message *msg,
|
|||
char *service, *old_owner, *new_owner;
|
||||
int ret = sd_bus_message_read(msg, "sss", &service, &old_owner, &new_owner);
|
||||
if (ret < 0) {
|
||||
wlr_log(WLR_ERROR, "Failed to parse owner change message: %s", strerror(-ret));
|
||||
sway_log(SWAY_ERROR, "Failed to parse owner change message: %s", strerror(-ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -148,7 +148,7 @@ bool init_host(struct swaybar_host *host, char *protocol,
|
|||
watcher_path, host->watcher_interface,
|
||||
"StatusNotifierItemRegistered", handle_sni_registered, tray);
|
||||
if (ret < 0) {
|
||||
wlr_log(WLR_ERROR, "Failed to subscribe to registering events: %s",
|
||||
sway_log(SWAY_ERROR, "Failed to subscribe to registering events: %s",
|
||||
strerror(-ret));
|
||||
goto error;
|
||||
}
|
||||
|
|
@ -156,7 +156,7 @@ bool init_host(struct swaybar_host *host, char *protocol,
|
|||
watcher_path, host->watcher_interface,
|
||||
"StatusNotifierItemUnregistered", handle_sni_unregistered, tray);
|
||||
if (ret < 0) {
|
||||
wlr_log(WLR_ERROR, "Failed to subscribe to unregistering events: %s",
|
||||
sway_log(SWAY_ERROR, "Failed to subscribe to unregistering events: %s",
|
||||
strerror(-ret));
|
||||
goto error;
|
||||
}
|
||||
|
|
@ -165,7 +165,7 @@ bool init_host(struct swaybar_host *host, char *protocol,
|
|||
"/org/freedesktop/DBus", "org.freedesktop.DBus", "NameOwnerChanged",
|
||||
handle_new_watcher, host);
|
||||
if (ret < 0) {
|
||||
wlr_log(WLR_ERROR, "Failed to subscribe to unregistering events: %s",
|
||||
sway_log(SWAY_ERROR, "Failed to subscribe to unregistering events: %s",
|
||||
strerror(-ret));
|
||||
goto error;
|
||||
}
|
||||
|
|
@ -180,7 +180,7 @@ bool init_host(struct swaybar_host *host, char *protocol,
|
|||
snprintf(host->service, service_len, "org.%s.StatusNotifierHost-%d", protocol, pid);
|
||||
ret = sd_bus_request_name(tray->bus, host->service, 0);
|
||||
if (ret < 0) {
|
||||
wlr_log(WLR_DEBUG, "Failed to acquire service name: %s", strerror(-ret));
|
||||
sway_log(SWAY_DEBUG, "Failed to acquire service name: %s", strerror(-ret));
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
|
@ -193,7 +193,7 @@ bool init_host(struct swaybar_host *host, char *protocol,
|
|||
sd_bus_slot_set_floating(unreg_slot, 1);
|
||||
sd_bus_slot_set_floating(watcher_slot, 1);
|
||||
|
||||
wlr_log(WLR_DEBUG, "Registered %s", host->service);
|
||||
sway_log(SWAY_DEBUG, "Registered %s", host->service);
|
||||
return true;
|
||||
error:
|
||||
sd_bus_slot_unref(reg_slot);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue