We truncate genuinely giant messages */
| 265 | |
| 266 | /* We truncate genuinely giant messages */ |
| 267 | static char *cap_header(const tal_t *ctx, struct log_hdr *hdr, const char *msg) |
| 268 | { |
| 269 | const size_t max = sizeof(((struct log_book *)0)->ringbuf) / 64; |
| 270 | if (hdr->msglen > max) { |
| 271 | msg = tal_fmt(ctx, "[TRUNCATED message from %zu bytes]: %.*s", |
| 272 | hdr->msglen, (int)max, msg); |
| 273 | hdr->msglen = strlen(msg); |
| 274 | } |
| 275 | if (hdr->iolen > max) { |
| 276 | msg = tal_fmt(ctx, "[TRUNCATED IO from %zu bytes]: %.*s", |
| 277 | hdr->iolen, (int)hdr->msglen, msg); |
| 278 | hdr->msglen = strlen(msg); |
| 279 | hdr->iolen = max; |
| 280 | } |
| 281 | return cast_const(char *, msg); |
| 282 | } |
| 283 | |
| 284 | static void add_entry(struct log_book *log, |
| 285 | const struct log_hdr *hdr, |