aboutsummaryrefslogtreecommitdiffstats
path: root/swaybar/status_line.c
diff options
context:
space:
mode:
authorLibravatar M Stoeckl <code@mstoeckl.com>2019-01-20 13:51:12 -0500
committerLibravatar emersion <contact@emersion.fr>2019-01-21 12:59:42 +0100
commit1211a81aad18bbc4d9e8fb9973238ad8e7e1f688 (patch)
tree5c3f60e0219cb8b4a1b7cafb760a871661866e32 /swaybar/status_line.c
parentLog libinput_config_status errors (diff)
downloadsway-1211a81aad18bbc4d9e8fb9973238ad8e7e1f688.tar.gz
sway-1211a81aad18bbc4d9e8fb9973238ad8e7e1f688.tar.zst
sway-1211a81aad18bbc4d9e8fb9973238ad8e7e1f688.zip
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.
Diffstat (limited to 'swaybar/status_line.c')
-rw-r--r--swaybar/status_line.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/swaybar/status_line.c b/swaybar/status_line.c
index f0e2c300..39ae8670 100644
--- a/swaybar/status_line.c
+++ b/swaybar/status_line.c
@@ -6,7 +6,7 @@
6#include <string.h> 6#include <string.h>
7#include <stdio.h> 7#include <stdio.h>
8#include <unistd.h> 8#include <unistd.h>
9#include <wlr/util/log.h> 9#include "log.h"
10#include "loop.h" 10#include "loop.h"
11#include "swaybar/bar.h" 11#include "swaybar/bar.h"
12#include "swaybar/config.h" 12#include "swaybar/config.h"
@@ -38,7 +38,7 @@ bool status_handle_readable(struct status_line *status) {
38 errno = 0; 38 errno = 0;
39 int available_bytes; 39 int available_bytes;
40 if (ioctl(status->read_fd, FIONREAD, &available_bytes) == -1) { 40 if (ioctl(status->read_fd, FIONREAD, &available_bytes) == -1) {
41 wlr_log(WLR_ERROR, "Unable to read status command output size"); 41 sway_log(SWAY_ERROR, "Unable to read status command output size");
42 status_error(status, "[error reading from status command]"); 42 status_error(status, "[error reading from status command]");
43 return true; 43 return true;
44 } 44 }
@@ -49,7 +49,7 @@ bool status_handle_readable(struct status_line *status) {
49 status->buffer = realloc(status->buffer, status->buffer_size); 49 status->buffer = realloc(status->buffer, status->buffer_size);
50 } 50 }
51 if (status->buffer == NULL) { 51 if (status->buffer == NULL) {
52 wlr_log_errno(WLR_ERROR, "Unable to read status line"); 52 sway_log_errno(SWAY_ERROR, "Unable to read status line");
53 status_error(status, "[error reading from status command]"); 53 status_error(status, "[error reading from status command]");
54 return true; 54 return true;
55 } 55 }
@@ -68,13 +68,13 @@ bool status_handle_readable(struct status_line *status) {
68 && (header = json_tokener_parse(status->buffer)) 68 && (header = json_tokener_parse(status->buffer))
69 && json_object_object_get_ex(header, "version", &version) 69 && json_object_object_get_ex(header, "version", &version)
70 && json_object_get_int(version) == 1) { 70 && json_object_get_int(version) == 1) {
71 wlr_log(WLR_DEBUG, "Using i3bar protocol."); 71 sway_log(SWAY_DEBUG, "Using i3bar protocol.");
72 status->protocol = PROTOCOL_I3BAR; 72 status->protocol = PROTOCOL_I3BAR;
73 73
74 json_object *click_events; 74 json_object *click_events;
75 if (json_object_object_get_ex(header, "click_events", &click_events) 75 if (json_object_object_get_ex(header, "click_events", &click_events)
76 && json_object_get_boolean(click_events)) { 76 && json_object_get_boolean(click_events)) {
77 wlr_log(WLR_DEBUG, "Enabling click events."); 77 sway_log(SWAY_DEBUG, "Enabling click events.");
78 status->click_events = true; 78 status->click_events = true;
79 if (write(status->write_fd, "[\n", 2) != 2) { 79 if (write(status->write_fd, "[\n", 2) != 2) {
80 status_error(status, "[failed to write to status command]"); 80 status_error(status, "[failed to write to status command]");
@@ -86,11 +86,11 @@ bool status_handle_readable(struct status_line *status) {
86 json_object *signal; 86 json_object *signal;
87 if (json_object_object_get_ex(header, "stop_signal", &signal)) { 87 if (json_object_object_get_ex(header, "stop_signal", &signal)) {
88 status->stop_signal = json_object_get_int(signal); 88 status->stop_signal = json_object_get_int(signal);
89 wlr_log(WLR_DEBUG, "Setting stop signal to %d", status->stop_signal); 89 sway_log(SWAY_DEBUG, "Setting stop signal to %d", status->stop_signal);
90 } 90 }
91 if (json_object_object_get_ex(header, "cont_signal", &signal)) { 91 if (json_object_object_get_ex(header, "cont_signal", &signal)) {
92 status->cont_signal = json_object_get_int(signal); 92 status->cont_signal = json_object_get_int(signal);
93 wlr_log(WLR_DEBUG, "Setting cont signal to %d", status->cont_signal); 93 sway_log(SWAY_DEBUG, "Setting cont signal to %d", status->cont_signal);
94 } 94 }
95 95
96 json_object_put(header); 96 json_object_put(header);
@@ -102,7 +102,7 @@ bool status_handle_readable(struct status_line *status) {
102 return i3bar_handle_readable(status); 102 return i3bar_handle_readable(status);
103 } 103 }
104 104
105 wlr_log(WLR_DEBUG, "Using text protocol."); 105 sway_log(SWAY_DEBUG, "Using text protocol.");
106 status->protocol = PROTOCOL_TEXT; 106 status->protocol = PROTOCOL_TEXT;
107 status->text = status->buffer; 107 status->text = status->buffer;
108 // intentional fall-through 108 // intentional fall-through
@@ -140,7 +140,7 @@ struct status_line *status_line_init(char *cmd) {
140 int pipe_read_fd[2]; 140 int pipe_read_fd[2];
141 int pipe_write_fd[2]; 141 int pipe_write_fd[2];
142 if (pipe(pipe_read_fd) != 0 || pipe(pipe_write_fd) != 0) { 142 if (pipe(pipe_read_fd) != 0 || pipe(pipe_write_fd) != 0) {
143 wlr_log(WLR_ERROR, "Unable to create pipes for status_command fork"); 143 sway_log(SWAY_ERROR, "Unable to create pipes for status_command fork");
144 exit(1); 144 exit(1);
145 } 145 }
146 146