From 1211a81aad18bbc4d9e8fb9973238ad8e7e1f688 Mon Sep 17 00:00:00 2001 From: M Stoeckl Date: Sun, 20 Jan 2019 13:51:12 -0500 Subject: 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. --- swaynag/main.c | 20 ++++++++++---------- swaynag/render.c | 2 +- swaynag/swaynag.c | 20 ++++++++++---------- 3 files changed, 21 insertions(+), 21 deletions(-) (limited to 'swaynag') diff --git a/swaynag/main.c b/swaynag/main.c index 9f00ac7e..4a785f40 100644 --- a/swaynag/main.c +++ b/swaynag/main.c @@ -47,13 +47,13 @@ int main(int argc, char **argv) { exit_code = launch_status; goto cleanup; } - wlr_log_init(debug ? WLR_DEBUG : WLR_ERROR, NULL); + sway_log_init(debug ? SWAY_DEBUG : SWAY_ERROR, NULL); if (!config_path) { config_path = swaynag_get_config_path(); } if (config_path) { - wlr_log(WLR_DEBUG, "Loading config file: %s", config_path); + sway_log(SWAY_DEBUG, "Loading config file: %s", config_path); int config_status = swaynag_load_config(config_path, &swaynag, types); free(config_path); if (config_status != 0) { @@ -77,7 +77,7 @@ int main(int argc, char **argv) { } if (!swaynag.message) { - wlr_log(WLR_ERROR, "No message passed. Please provide --message/-m"); + sway_log(SWAY_ERROR, "No message passed. Please provide --message/-m"); exit_code = EXIT_FAILURE; goto cleanup; } @@ -106,15 +106,15 @@ int main(int argc, char **argv) { free(swaynag.details.button_details); } - wlr_log(WLR_DEBUG, "Output: %s", swaynag.type->output); - wlr_log(WLR_DEBUG, "Anchors: %d", swaynag.type->anchors); - wlr_log(WLR_DEBUG, "Type: %s", swaynag.type->name); - wlr_log(WLR_DEBUG, "Message: %s", swaynag.message); - wlr_log(WLR_DEBUG, "Font: %s", swaynag.type->font); - wlr_log(WLR_DEBUG, "Buttons"); + sway_log(SWAY_DEBUG, "Output: %s", swaynag.type->output); + sway_log(SWAY_DEBUG, "Anchors: %d", swaynag.type->anchors); + sway_log(SWAY_DEBUG, "Type: %s", swaynag.type->name); + sway_log(SWAY_DEBUG, "Message: %s", swaynag.message); + sway_log(SWAY_DEBUG, "Font: %s", swaynag.type->font); + sway_log(SWAY_DEBUG, "Buttons"); for (int i = 0; i < swaynag.buttons->length; i++) { struct swaynag_button *button = swaynag.buttons->items[i]; - wlr_log(WLR_DEBUG, "\t[%s] `%s`", button->text, button->action); + sway_log(SWAY_DEBUG, "\t[%s] `%s`", button->text, button->action); } signal(SIGTERM, sig_handler); diff --git a/swaynag/render.c b/swaynag/render.c index 7db9fe60..661e27a1 100644 --- a/swaynag/render.c +++ b/swaynag/render.c @@ -281,7 +281,7 @@ void render_frame(struct swaynag *swaynag) { swaynag->width * swaynag->scale, swaynag->height * swaynag->scale); if (!swaynag->current_buffer) { - wlr_log(WLR_DEBUG, "Failed to get buffer. Skipping frame."); + sway_log(SWAY_DEBUG, "Failed to get buffer. Skipping frame."); goto cleanup; } diff --git a/swaynag/swaynag.c b/swaynag/swaynag.c index 186e9011..f0c6a3c5 100644 --- a/swaynag/swaynag.c +++ b/swaynag/swaynag.c @@ -21,24 +21,24 @@ static bool terminal_execute(char *terminal, char *command) { char fname[] = "/tmp/swaynagXXXXXX"; FILE *tmp= fdopen(mkstemp(fname), "w"); if (!tmp) { - wlr_log(WLR_ERROR, "Failed to create temp script"); + sway_log(SWAY_ERROR, "Failed to create temp script"); return false; } - wlr_log(WLR_DEBUG, "Created temp script: %s", fname); + sway_log(SWAY_DEBUG, "Created temp script: %s", fname); fprintf(tmp, "#!/bin/sh\nrm %s\n%s", fname, command); fclose(tmp); chmod(fname, S_IRUSR | S_IWUSR | S_IXUSR); char *cmd = malloc(sizeof(char) * (strlen(terminal) + strlen(" -e ") + strlen(fname) + 1)); sprintf(cmd, "%s -e %s", terminal, fname); execl("/bin/sh", "/bin/sh", "-c", cmd, NULL); - wlr_log_errno(WLR_ERROR, "Failed to run command, execl() returned."); + sway_log_errno(SWAY_ERROR, "Failed to run command, execl() returned."); free(cmd); return false; } static void swaynag_button_execute(struct swaynag *swaynag, struct swaynag_button *button) { - wlr_log(WLR_DEBUG, "Executing [%s]: %s", button->text, button->action); + sway_log(SWAY_DEBUG, "Executing [%s]: %s", button->text, button->action); if (button->type == SWAYNAG_ACTION_DISMISS) { swaynag->run_display = false; } else if (button->type == SWAYNAG_ACTION_EXPAND) { @@ -52,14 +52,14 @@ static void swaynag_button_execute(struct swaynag *swaynag, // Child of the child. Will be reparented to the init process char *terminal = getenv("TERMINAL"); if (button->terminal && terminal && strlen(terminal)) { - wlr_log(WLR_DEBUG, "Found $TERMINAL: %s", terminal); + sway_log(SWAY_DEBUG, "Found $TERMINAL: %s", terminal); if (!terminal_execute(terminal, button->action)) { swaynag_destroy(swaynag); exit(EXIT_FAILURE); } } else { if (button->terminal) { - wlr_log(WLR_DEBUG, + sway_log(SWAY_DEBUG, "$TERMINAL not found. Running directly"); } execl("/bin/sh", "/bin/sh", "-c", button->action, NULL); @@ -98,7 +98,7 @@ static void surface_enter(void *data, struct wl_surface *surface, struct swaynag_output *swaynag_output; wl_list_for_each(swaynag_output, &swaynag->outputs, link) { if (swaynag_output->wl_output == output) { - wlr_log(WLR_DEBUG, "Surface enter on output %s", + sway_log(SWAY_DEBUG, "Surface enter on output %s", swaynag_output->name); swaynag->output = swaynag_output; swaynag->scale = swaynag->output->scale; @@ -273,10 +273,10 @@ static void xdg_output_handle_name(void *data, struct zxdg_output_v1 *xdg_output, const char *name) { struct swaynag_output *swaynag_output = data; char *outname = swaynag_output->swaynag->type->output; - wlr_log(WLR_DEBUG, "Checking against output %s for %s", name, outname); + sway_log(SWAY_DEBUG, "Checking against output %s for %s", name, outname); if (!swaynag_output->swaynag->output && outname && name && strcmp(outname, name) == 0) { - wlr_log(WLR_DEBUG, "Using output %s", name); + sway_log(SWAY_DEBUG, "Using output %s", name); swaynag_output->swaynag->output = swaynag_output; } swaynag_output->name = strdup(name); @@ -368,7 +368,7 @@ void swaynag_setup(struct swaynag *swaynag) { } if (!swaynag->output && swaynag->type->output) { - wlr_log(WLR_ERROR, "Output '%s' not found", swaynag->type->output); + sway_log(SWAY_ERROR, "Output '%s' not found", swaynag->type->output); swaynag_destroy(swaynag); exit(EXIT_FAILURE); } -- cgit v1.2.3-54-g00ecf