(w: &mut W, debug_log: &DebugLog)
| 30 | } |
| 31 | |
| 32 | fn write_debug_log<W: Write>(w: &mut W, debug_log: &DebugLog) -> Result { |
| 33 | writeln!(w, "<!doctype html>")?; |
| 34 | writeln!(w, "<html>")?; |
| 35 | writeln!(w, "<head>")?; |
| 36 | writeln!(w, r#"<meta charset="utf-8">"#)?; |
| 37 | writeln!(w, "<title>prqlc debug log {}</title>", debug_log.started_at)?; |
| 38 | writeln!(w, r#"<meta name="generator" content="prqlc">"#)?; |
| 39 | writeln!(w, r#"<meta name="robots" content="noindex">"#)?; |
| 40 | writeln!(w, "<style>{CSS_STYLES}</style>")?; |
| 41 | writeln!(w, "<script>{JS_SCRIPT}</script>")?; |
| 42 | writeln!(w, "</head>")?; |
| 43 | writeln!(w, "<body>")?; |
| 44 | |
| 45 | // header |
| 46 | { |
| 47 | writeln!(w, "<header>")?; |
| 48 | writeln!(w, "<h1>prqlc debug log</h1>")?; |
| 49 | |
| 50 | write_key_values( |
| 51 | w, |
| 52 | &[ |
| 53 | ("started_at", &debug_log.started_at), |
| 54 | ("version", &debug_log.version), |
| 55 | ], |
| 56 | )?; |
| 57 | writeln!(w, "</header>")?; |
| 58 | } |
| 59 | |
| 60 | // pre-stage entries (this should be mostly source PRQL) |
| 61 | for (index, entry) in debug_log.entries.iter().enumerate() { |
| 62 | if let DebugEntryKind::NewStage(_) = &entry.kind { |
| 63 | break; |
| 64 | } |
| 65 | |
| 66 | match &entry.kind { |
| 67 | DebugEntryKind::Message(message) => { |
| 68 | write_message(w, message)?; |
| 69 | } |
| 70 | _ => { |
| 71 | write_titled_entry(w, index, entry)?; |
| 72 | } |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | { |
| 77 | writeln!(w, "<div class=message-filter>")?; |
| 78 | for level in ["off", "error", "warn", "info", "debug", "trace"] { |
| 79 | writeln!( |
| 80 | w, |
| 81 | r#"<input type="radio" name="message-filter" id="msg-filter-{level}">"# |
| 82 | )?; |
| 83 | writeln!(w, r#"<label for="msg-filter-{level}">{level}</label>"#)?; |
| 84 | } |
| 85 | |
| 86 | writeln!(w, "</div>")?; |
| 87 | } |
| 88 | |
| 89 | { |
no test coverage detected