Merge pull request #430 from crondog/swaybarlog

swaybar: fix logging
master
Drew DeVault 9 years ago
commit 27ab7d8982

@ -744,7 +744,7 @@ void free_status_block(void *item) {
void parse_json(const char *text) { void parse_json(const char *text) {
json_object *results = json_tokener_parse(text); json_object *results = json_tokener_parse(text);
if (!results) { if (!results) {
sway_log(L_DEBUG, "xxx Failed to parse json"); sway_log(L_DEBUG, "Failed to parse json");
return; return;
} }
@ -1185,22 +1185,23 @@ void poll_for_update() {
} }
int main(int argc, char **argv) { int main(int argc, char **argv) {
init_log(L_DEBUG);
char *socket_path = NULL; char *socket_path = NULL;
char *bar_id = NULL; char *bar_id = NULL;
bool debug = false;
static struct option long_options[] = { static struct option long_options[] = {
{"version", no_argument, NULL, 'v'}, {"version", no_argument, NULL, 'v'},
{"socket", required_argument, NULL, 's'}, {"socket", required_argument, NULL, 's'},
{"bar_id", required_argument, NULL, 'b'}, {"bar_id", required_argument, NULL, 'b'},
{"debug", required_argument, NULL, 'd'},
{0, 0, 0, 0} {0, 0, 0, 0}
}; };
int c; int c;
while (1) { while (1) {
int option_index = 0; int option_index = 0;
c = getopt_long(argc, argv, "vs:b:", long_options, &option_index); c = getopt_long(argc, argv, "vs:b:d", long_options, &option_index);
if (c == -1) { if (c == -1) {
break; break;
} }
@ -1219,6 +1220,9 @@ int main(int argc, char **argv) {
#endif #endif
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
break; break;
case 'd': // Debug
debug = true;
break;
default: default:
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
@ -1228,6 +1232,12 @@ int main(int argc, char **argv) {
sway_abort("No bar_id passed. Provide --bar_id or let sway start swaybar"); sway_abort("No bar_id passed. Provide --bar_id or let sway start swaybar");
} }
if (debug) {
init_log(L_DEBUG);
} else {
init_log(L_ERROR);
}
registry = registry_poll(); registry = registry_poll();
if (!registry->desktop_shell) { if (!registry->desktop_shell) {

Loading…
Cancel
Save