| 1 | #include <ndjson.h> |
| 2 | #include <nightmare/record.h> |
| 3 | |
| 4 | NDJSON_DECLARE(nightmare_boot, NDJSON_SECTION_NIGHTMARE, NDJSON_KIND_BOOT, 1, |
| 5 | NDJSON_STR(test), NDJSON_HEX(seed), NDJSON_STR(seed_policy), |
| 6 | NDJSON_STR(seed_mode), NDJSON_I64(intensity), |
| 7 | NDJSON_U64(intensity_val), NDJSON_U64(workers), NDJSON_U64(smp), |
| 8 | NDJSON_U64(mem_mib), NDJSON_STR(caps), NDJSON_STR(campaign_id), |
| 9 | NDJSON_U64(boot_index), NDJSON_STR(commit)); |
| 10 | |
| 11 | NDJSON_DECLARE(nightmare_stat, NDJSON_SECTION_NIGHTMARE, NDJSON_KIND_STAT, 1, |
| 12 | NDJSON_U64(progress), NDJSON_U64(workers)); |
| 13 | |
| 14 | NDJSON_DECLARE(nightmare_quiesce, NDJSON_SECTION_NIGHTMARE, NDJSON_KIND_QUIESCE, |
| 15 | 1, NDJSON_STR(result), NDJSON_U64(checks)); |
| 16 | |
| 17 | NDJSON_DECLARE(nightmare_finding, NDJSON_SECTION_NIGHTMARE, NDJSON_KIND_FINDING, |
| 18 | 1, NDJSON_STR(kind), NDJSON_STR(tier), NDJSON_STR(sig), |
| 19 | NDJSON_STR(site), NDJSON_STR(msg)); |
| 20 | |
| 21 | NDJSON_DECLARE(nightmare_verdict, NDJSON_SECTION_NIGHTMARE, NDJSON_KIND_VERDICT, |
| 22 | 1, NDJSON_STR(result), NDJSON_STR(reason), |
| 23 | NDJSON_U64(duration_ms), NDJSON_U64(progress), |
| 24 | NDJSON_U64(findings), NDJSON_STR(msg)); |
| 25 | |
| 26 | void nightmare_record_boot(const struct nightmare_boot_record *r) { |
| 27 | ndjson_emit(nightmare_boot, .test = r->test, .seed = r->seed, |
| 28 | .seed_policy = r->seed_policy, .seed_mode = r->seed_mode, |
| 29 | .intensity = r->intensity, .intensity_val = r->intensity_val, |
| 30 | .workers = r->workers, .smp = r->smp, .mem_mib = r->mem_mib, |
| 31 | .caps = r->caps, .campaign_id = r->campaign_id, |
| 32 | .boot_index = r->boot_index, .commit = r->commit); |
| 33 | } |
| 34 | |
| 35 | void nightmare_record_stat(uint64_t progress, uint64_t workers) { |
| 36 | ndjson_emit(nightmare_stat, .progress = progress, .workers = workers); |
| 37 | } |
| 38 | |
| 39 | void nightmare_record_quiesce(const struct nightmare_quiesce_record *r) { |
| 40 | ndjson_emit(nightmare_quiesce, .result = r->result, .checks = r->checks); |
| 41 | } |
| 42 | |
| 43 | void nightmare_record_finding(const struct nightmare_finding_record *r) { |
| 44 | ndjson_emit(nightmare_finding, .kind = r->kind, .tier = r->tier, |
| 45 | .sig = r->sig, .site = r->site, .msg = r->msg); |
| 46 | } |
| 47 | |
| 48 | void nightmare_record_verdict(const struct nightmare_verdict_record *r) { |
| 49 | ndjson_emit(nightmare_verdict, .result = r->result, .reason = r->reason, |
| 50 | .duration_ms = r->duration_ms, .progress = r->progress, |
| 51 | .findings = r->findings, .msg = r->msg); |
| 52 | } |
| 53 | |