diff options
author | S. Christoffer Eliesen <christoffer@eliesen.no> | 2015-10-25 00:34:57 +0200 |
---|---|---|
committer | S. Christoffer Eliesen <christoffer@eliesen.no> | 2015-10-25 13:14:28 +0100 |
commit | 5a70853253633482b09ebdcbde0f4ec7502c7527 (patch) | |
tree | aa6841b0faf26ef4bd01010029b8e3a4e0d31c50 | |
parent | sway/output: Create, move code from handlers.c here. (diff) | |
download | sway-5a70853253633482b09ebdcbde0f4ec7502c7527.tar.gz sway-5a70853253633482b09ebdcbde0f4ec7502c7527.tar.zst sway-5a70853253633482b09ebdcbde0f4ec7502c7527.zip |
log: Add swayc_log, use at a few key places.
swayc_log works just like sway_log, but appends type and name from given
container to the log output.
-rw-r--r-- | include/log.h | 2 | ||||
-rw-r--r-- | sway/focus.c | 2 | ||||
-rw-r--r-- | sway/layout.c | 2 | ||||
-rw-r--r-- | sway/log.c | 27 |
4 files changed, 31 insertions, 2 deletions
diff --git a/include/log.h b/include/log.h index f8deaf26..806725a6 100644 --- a/include/log.h +++ b/include/log.h | |||
@@ -23,4 +23,6 @@ bool _sway_assert(bool condition, const char* format, ...) __attribute__((format | |||
23 | void error_handler(int sig); | 23 | void error_handler(int sig); |
24 | 24 | ||
25 | void layout_log(const swayc_t *c, int depth); | 25 | void layout_log(const swayc_t *c, int depth); |
26 | const char *swayc_type_string(enum swayc_types type); | ||
27 | void swayc_log(log_importance_t verbosity, swayc_t *cont, const char* format, ...) __attribute__((format(printf,3,4))); | ||
26 | #endif | 28 | #endif |
diff --git a/sway/focus.c b/sway/focus.c index 0c1f8c9e..1aa7579b 100644 --- a/sway/focus.c +++ b/sway/focus.c | |||
@@ -76,7 +76,7 @@ bool set_focused_container(swayc_t *c) { | |||
76 | if (locked_container_focus || !c) { | 76 | if (locked_container_focus || !c) { |
77 | return false; | 77 | return false; |
78 | } | 78 | } |
79 | sway_log(L_DEBUG, "Setting focus to %p:%ld", c, c->handle); | 79 | swayc_log(L_DEBUG, c, "Setting focus to %p:%ld", c, c->handle); |
80 | 80 | ||
81 | // Get workspace for c, get that workspaces current focused container. | 81 | // Get workspace for c, get that workspaces current focused container. |
82 | swayc_t *workspace = swayc_active_workspace_for(c); | 82 | swayc_t *workspace = swayc_active_workspace_for(c); |
diff --git a/sway/layout.c b/sway/layout.c index 3cd873d6..6388a9b2 100644 --- a/sway/layout.c +++ b/sway/layout.c | |||
@@ -349,7 +349,7 @@ void update_geometry(swayc_t *container) { | |||
349 | static void arrange_windows_r(swayc_t *container, double width, double height) { | 349 | static void arrange_windows_r(swayc_t *container, double width, double height) { |
350 | int i; | 350 | int i; |
351 | if (width == -1 || height == -1) { | 351 | if (width == -1 || height == -1) { |
352 | sway_log(L_DEBUG, "Arranging layout for %p", container); | 352 | swayc_log(L_DEBUG, container, "Arranging layout for %p", container); |
353 | width = container->width; | 353 | width = container->width; |
354 | height = container->height; | 354 | height = container->height; |
355 | } | 355 | } |
@@ -187,4 +187,31 @@ void layout_log(const swayc_t *c, int depth) { | |||
187 | } | 187 | } |
188 | } | 188 | } |
189 | } | 189 | } |
190 | |||
191 | const char *swayc_type_string(enum swayc_types type) { | ||
192 | return type == C_ROOT ? "ROOT" : | ||
193 | type == C_OUTPUT ? "OUTPUT" : | ||
194 | type == C_WORKSPACE ? "WORKSPACE" : | ||
195 | type == C_CONTAINER ? "CONTAINER" : | ||
196 | type == C_VIEW ? "VIEW" : | ||
197 | "UNKNOWN"; | ||
198 | } | ||
199 | |||
200 | // Like sway_log, but also appends some info about given container to log output. | ||
201 | void swayc_log(log_importance_t verbosity, swayc_t *cont, const char* format, ...) { | ||
202 | sway_assert(cont, "swayc_log: no container ..."); | ||
203 | va_list args; | ||
204 | va_start(args, format); | ||
205 | char *txt = malloc(128); | ||
206 | vsprintf(txt, format, args); | ||
207 | va_end(args); | ||
208 | |||
209 | char *debug_txt = malloc(32); | ||
210 | snprintf(debug_txt, 32, "%s '%s'", swayc_type_string(cont->type), cont->name); | ||
211 | |||
212 | sway_log(verbosity, "%s (%s)", txt, debug_txt); | ||
213 | free(txt); | ||
214 | free(debug_txt); | ||
215 | } | ||
216 | |||
190 | /* XXX:DEBUG:XXX */ | 217 | /* XXX:DEBUG:XXX */ |