diff options
author | 2016-01-03 22:55:43 -0500 | |
---|---|---|
committer | 2016-01-03 22:55:43 -0500 | |
commit | 27ab7d898219ff9a5aa2126d9f4ea9ee82403254 (patch) | |
tree | f23181b28d497236296acd4606e945e31a279374 /swaybar/main.c | |
parent | Merge pull request #429 from mikkeloscar/bar-workspace-buttons (diff) | |
parent | swaybar: fix logging (diff) | |
download | sway-27ab7d898219ff9a5aa2126d9f4ea9ee82403254.tar.gz sway-27ab7d898219ff9a5aa2126d9f4ea9ee82403254.tar.zst sway-27ab7d898219ff9a5aa2126d9f4ea9ee82403254.zip |
Merge pull request #430 from crondog/swaybarlog
swaybar: fix logging
Diffstat (limited to 'swaybar/main.c')
-rw-r--r-- | swaybar/main.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/swaybar/main.c b/swaybar/main.c index e96c9df0..e3967846 100644 --- a/swaybar/main.c +++ b/swaybar/main.c | |||
@@ -744,7 +744,7 @@ void free_status_block(void *item) { | |||
744 | void parse_json(const char *text) { | 744 | void parse_json(const char *text) { |
745 | json_object *results = json_tokener_parse(text); | 745 | json_object *results = json_tokener_parse(text); |
746 | if (!results) { | 746 | if (!results) { |
747 | sway_log(L_DEBUG, "xxx Failed to parse json"); | 747 | sway_log(L_DEBUG, "Failed to parse json"); |
748 | return; | 748 | return; |
749 | } | 749 | } |
750 | 750 | ||
@@ -1185,22 +1185,23 @@ void poll_for_update() { | |||
1185 | } | 1185 | } |
1186 | 1186 | ||
1187 | int main(int argc, char **argv) { | 1187 | int main(int argc, char **argv) { |
1188 | init_log(L_DEBUG); | ||
1189 | 1188 | ||
1190 | char *socket_path = NULL; | 1189 | char *socket_path = NULL; |
1191 | char *bar_id = NULL; | 1190 | char *bar_id = NULL; |
1191 | bool debug = false; | ||
1192 | 1192 | ||
1193 | static struct option long_options[] = { | 1193 | static struct option long_options[] = { |
1194 | {"version", no_argument, NULL, 'v'}, | 1194 | {"version", no_argument, NULL, 'v'}, |
1195 | {"socket", required_argument, NULL, 's'}, | 1195 | {"socket", required_argument, NULL, 's'}, |
1196 | {"bar_id", required_argument, NULL, 'b'}, | 1196 | {"bar_id", required_argument, NULL, 'b'}, |
1197 | {"debug", required_argument, NULL, 'd'}, | ||
1197 | {0, 0, 0, 0} | 1198 | {0, 0, 0, 0} |
1198 | }; | 1199 | }; |
1199 | 1200 | ||
1200 | int c; | 1201 | int c; |
1201 | while (1) { | 1202 | while (1) { |
1202 | int option_index = 0; | 1203 | int option_index = 0; |
1203 | c = getopt_long(argc, argv, "vs:b:", long_options, &option_index); | 1204 | c = getopt_long(argc, argv, "vs:b:d", long_options, &option_index); |
1204 | if (c == -1) { | 1205 | if (c == -1) { |
1205 | break; | 1206 | break; |
1206 | } | 1207 | } |
@@ -1219,6 +1220,9 @@ int main(int argc, char **argv) { | |||
1219 | #endif | 1220 | #endif |
1220 | exit(EXIT_SUCCESS); | 1221 | exit(EXIT_SUCCESS); |
1221 | break; | 1222 | break; |
1223 | case 'd': // Debug | ||
1224 | debug = true; | ||
1225 | break; | ||
1222 | default: | 1226 | default: |
1223 | exit(EXIT_FAILURE); | 1227 | exit(EXIT_FAILURE); |
1224 | } | 1228 | } |
@@ -1227,6 +1231,12 @@ int main(int argc, char **argv) { | |||
1227 | if (!bar_id) { | 1231 | if (!bar_id) { |
1228 | sway_abort("No bar_id passed. Provide --bar_id or let sway start swaybar"); | 1232 | sway_abort("No bar_id passed. Provide --bar_id or let sway start swaybar"); |
1229 | } | 1233 | } |
1234 | |||
1235 | if (debug) { | ||
1236 | init_log(L_DEBUG); | ||
1237 | } else { | ||
1238 | init_log(L_ERROR); | ||
1239 | } | ||
1230 | 1240 | ||
1231 | registry = registry_poll(); | 1241 | registry = registry_poll(); |
1232 | 1242 | ||