diff options
Diffstat (limited to 'sway/log.c')
-rw-r--r-- | sway/log.c | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -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 */ |