| 650 | } |
| 651 | |
| 652 | void json_notify_fmt(struct command *cmd, |
| 653 | enum log_level level, |
| 654 | const char *fmt, ...) |
| 655 | { |
| 656 | va_list ap; |
| 657 | struct json_stream *js; |
| 658 | const char *msg; |
| 659 | |
| 660 | va_start(ap, fmt); |
| 661 | msg = tal_vfmt(tmpctx, fmt, ap); |
| 662 | va_end(ap); |
| 663 | |
| 664 | /* Help for tests */ |
| 665 | log_debug(cmd->ld->log, "NOTIFY %s %s %s", |
| 666 | cmd->id, log_level_name(level), msg); |
| 667 | if (!cmd->send_notifications) |
| 668 | return; |
| 669 | |
| 670 | js = json_stream_raw_for_cmd(cmd); |
| 671 | |
| 672 | json_object_start(js, NULL); |
| 673 | json_add_string(js, "jsonrpc", "2.0"); |
| 674 | json_add_string(js, "method", "message"); |
| 675 | json_object_start(js, "params"); |
| 676 | json_add_id(js, cmd->id); |
| 677 | json_add_string(js, "level", log_level_name(level)); |
| 678 | json_add_string(js, "message", msg); |
| 679 | json_object_end(js); |
| 680 | json_object_end(js); |
| 681 | |
| 682 | json_stream_double_cr(js); |
| 683 | json_stream_flush(js); |
| 684 | } |
| 685 | |
| 686 | struct json_stream *json_stream_raw_for_cmd(struct command *cmd) |
| 687 | { |
no test coverage detected