Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

log/jsonrpc: getlog was returning invalid JSON. #35

Merged
merged 1 commit into from
Sep 27, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions daemon/jsonrpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ struct log_info {
static void add_skipped(struct log_info *info)
{
if (info->num_skipped) {
json_array_start(info->response, NULL);
json_object_start(info->response, NULL);
json_add_string(info->response, "type", "SKIPPED");
json_add_num(info->response, "num_skipped", info->num_skipped);
json_array_end(info->response);
json_object_end(info->response);
info->num_skipped = 0;
}
}
Expand Down Expand Up @@ -106,7 +106,7 @@ static void log_to_json(unsigned int skipped,

add_skipped(info);

json_array_start(info->response, NULL);
json_object_start(info->response, NULL);
json_add_string(info->response, "type",
level == LOG_BROKEN ? "BROKEN"
: level == LOG_UNUSUAL ? "UNUSUAL"
Expand All @@ -126,7 +126,7 @@ static void log_to_json(unsigned int skipped,
} else
json_add_string(info->response, "log", log);

json_array_end(info->response);
json_object_end(info->response);
}

static void json_getlog(struct command *cmd,
Expand Down Expand Up @@ -160,9 +160,9 @@ static void json_getlog(struct command *cmd,
json_add_time(info.response, "creation_time", log_init_time(lr)->ts);
json_add_num(info.response, "bytes_used", (unsigned int)log_used(lr));
json_add_num(info.response, "bytes_max", (unsigned int)log_max_mem(lr));
json_object_start(info.response, "log");
json_array_start(info.response, "log");
log_each_line(lr, log_to_json, &info);
json_object_end(info.response);
json_array_end(info.response);
json_object_end(info.response);
command_success(cmd, info.response);
}
Expand Down