diff options
Diffstat (limited to 'sway/debug_log.c')
-rw-r--r-- | sway/debug_log.c | 103 |
1 files changed, 0 insertions, 103 deletions
diff --git a/sway/debug_log.c b/sway/debug_log.c deleted file mode 100644 index d1eafae8..00000000 --- a/sway/debug_log.c +++ /dev/null | |||
@@ -1,103 +0,0 @@ | |||
1 | #include "log.h" | ||
2 | #include "sway.h" | ||
3 | #include <stdarg.h> | ||
4 | #include <stdio.h> | ||
5 | #include <stdlib.h> | ||
6 | #include <libgen.h> | ||
7 | #include <fcntl.h> | ||
8 | #include <unistd.h> | ||
9 | #include <signal.h> | ||
10 | #include <errno.h> | ||
11 | #include <string.h> | ||
12 | #include <stringop.h> | ||
13 | #include "sway/workspace.h" | ||
14 | |||
15 | /* XXX:DEBUG:XXX */ | ||
16 | static void container_log(const swayc_t *c, int depth) { | ||
17 | fprintf(stderr, "focus:%c", | ||
18 | c == get_focused_view(&root_container) ? 'K': | ||
19 | c == get_focused_container(&root_container) ? 'F' : // Focused | ||
20 | c == swayc_active_workspace() ? 'W' : // active workspace | ||
21 | c == &root_container ? 'R' : // root | ||
22 | 'X');// not any others | ||
23 | for (int i = 6; i > depth; i--) { fprintf(stderr, " "); } | ||
24 | fprintf(stderr,"|(%p)",c); | ||
25 | fprintf(stderr,"(p:%-8p)",c->parent); | ||
26 | fprintf(stderr,"(f:%-8p)",c->focused); | ||
27 | fprintf(stderr,"(h:%2" PRIuPTR ")",c->handle); | ||
28 | fprintf(stderr,"Type:%-4s|", | ||
29 | c->type == C_ROOT ? "root" : | ||
30 | c->type == C_OUTPUT ? "op" : | ||
31 | c->type == C_WORKSPACE ? "ws" : | ||
32 | c->type == C_CONTAINER ? "cont" : | ||
33 | c->type == C_VIEW ? "view" : "?"); | ||
34 | fprintf(stderr,"layout:%-5s|", | ||
35 | c->layout == L_NONE ? "-" : | ||
36 | c->layout == L_HORIZ ? "Horiz": | ||
37 | c->layout == L_VERT ? "Vert": | ||
38 | c->layout == L_STACKED ? "Stack": | ||
39 | c->layout == L_TABBED ? "Tab": | ||
40 | c->layout == L_FLOATING ? "Float": | ||
41 | c->layout == L_AUTO_LEFT ? "A_lft": | ||
42 | c->layout == L_AUTO_RIGHT ? "A_rgt": | ||
43 | c->layout == L_AUTO_TOP ? "A_top": | ||
44 | c->layout == L_AUTO_BOTTOM ? "A_bot": | ||
45 | "Unknown"); | ||
46 | fprintf(stderr, "w:%4.f|h:%4.f|", c->width, c->height); | ||
47 | fprintf(stderr, "x:%4.f|y:%4.f|", c->x, c->y); | ||
48 | fprintf(stderr, "g:%3d|",c->gaps); | ||
49 | fprintf(stderr, "vis:%c|", c->visible?'t':'f'); | ||
50 | fprintf(stderr, "children:%2d|",c->children?c->children->length:0); | ||
51 | fprintf(stderr, "name:%.16s\n", c->name); | ||
52 | } | ||
53 | void layout_log(const swayc_t *c, int depth) { | ||
54 | if (L_DEBUG > get_log_level()) return; | ||
55 | int i, d; | ||
56 | int e = c->children ? c->children->length : 0; | ||
57 | container_log(c, depth); | ||
58 | if (e) { | ||
59 | for (i = 0; i < e; ++i) { | ||
60 | fputc('|',stderr); | ||
61 | for (d = 0; d < depth; ++d) fputc('-', stderr); | ||
62 | layout_log(c->children->items[i], depth + 1); | ||
63 | } | ||
64 | } | ||
65 | if (c->type == C_WORKSPACE) { | ||
66 | e = c->floating?c->floating->length:0; | ||
67 | if (e) { | ||
68 | for (i = 0; i < e; ++i) { | ||
69 | fputc('|',stderr); | ||
70 | for (d = 0; d < depth; ++d) fputc('=', stderr); | ||
71 | layout_log(c->floating->items[i], depth + 1); | ||
72 | } | ||
73 | } | ||
74 | } | ||
75 | } | ||
76 | |||
77 | const char *swayc_type_string(enum swayc_types type) { | ||
78 | return type == C_ROOT ? "ROOT" : | ||
79 | type == C_OUTPUT ? "OUTPUT" : | ||
80 | type == C_WORKSPACE ? "WORKSPACE" : | ||
81 | type == C_CONTAINER ? "CONTAINER" : | ||
82 | type == C_VIEW ? "VIEW" : | ||
83 | "UNKNOWN"; | ||
84 | } | ||
85 | |||
86 | // Like sway_log, but also appends some info about given container to log output. | ||
87 | void swayc_log(log_importance_t verbosity, swayc_t *cont, const char* format, ...) { | ||
88 | sway_assert(cont, "swayc_log: no container ..."); | ||
89 | va_list args; | ||
90 | va_start(args, format); | ||
91 | char *txt = malloc(128); | ||
92 | vsprintf(txt, format, args); | ||
93 | va_end(args); | ||
94 | |||
95 | char *debug_txt = malloc(32); | ||
96 | snprintf(debug_txt, 32, "%s '%s'", swayc_type_string(cont->type), cont->name); | ||
97 | |||
98 | sway_log(verbosity, "%s (%s)", txt, debug_txt); | ||
99 | free(txt); | ||
100 | free(debug_txt); | ||
101 | } | ||
102 | |||
103 | /* XXX:DEBUG:XXX */ | ||