relux_runtime/observe/structured/builder/
io.rs1use std::time::Duration;
7
8use relux_core::diagnostics::IrSpan;
9
10use super::StructuredLogBuilder;
11use crate::observe::progress::ProgressEvent;
12use crate::observe::structured::event::EventKind;
13use crate::observe::structured::span::SpanId;
14
15impl StructuredLogBuilder {
16 pub fn emit_send(
17 &self,
18 span: SpanId,
19 shell: &str,
20 marker: &str,
21 data: &str,
22 location: Option<&IrSpan>,
23 ) {
24 self.push_event(
25 span,
26 Some(shell),
27 Some(marker),
28 location,
29 EventKind::Send {
30 data: data.to_string(),
31 },
32 );
33 self.push_progress(ProgressEvent::Send);
34 }
35
36 pub fn emit_recv(
37 &self,
38 span: SpanId,
39 shell: &str,
40 marker: &str,
41 data: &str,
42 location: Option<&IrSpan>,
43 ) {
44 self.push_event(
45 span,
46 Some(shell),
47 Some(marker),
48 location,
49 EventKind::Recv {
50 data: data.to_string(),
51 },
52 );
53 }
54
55 pub fn emit_sleep_start(
56 &self,
57 span: SpanId,
58 shell: &str,
59 marker: &str,
60 duration: Duration,
61 location: Option<&IrSpan>,
62 ) {
63 self.push_event(
64 span,
65 Some(shell),
66 Some(marker),
67 location,
68 EventKind::SleepStart { duration },
69 );
70 self.push_progress(ProgressEvent::SleepStart);
71 }
72
73 pub fn emit_sleep_done(
74 &self,
75 span: SpanId,
76 shell: &str,
77 marker: &str,
78 location: Option<&IrSpan>,
79 ) {
80 self.push_event(
81 span,
82 Some(shell),
83 Some(marker),
84 location,
85 EventKind::SleepDone,
86 );
87 self.push_progress(ProgressEvent::SleepDone);
88 }
89}