MCPcopy
hub / github.com/bettercap/bettercap / recorder

Method recorder

modules/api_rest/api_rest_record.go:44–78  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

42}
43
44func (mod *RestAPI) recorder() {
45 clock := time.Duration(mod.recClock) * time.Second
46
47 mod.recTime = 0
48 mod.recording = true
49 mod.replaying = false
50 mod.record = recording.New(mod.recordFileName)
51
52 mod.Info("started recording to %s (clock %s) ...", mod.recordFileName, clock)
53
54 mod.recordWait.Add(1)
55 defer mod.recordWait.Done()
56
57 tick := time.NewTicker(1 * time.Second)
58 lastSampled := time.Time{}
59
60 for range tick.C {
61 if !mod.recording {
62 break
63 }
64
65 mod.recTime++
66
67 if time.Since(lastSampled) >= clock {
68 lastSampled = time.Now()
69 if err := mod.recordState(); err != nil {
70 mod.Error("error while recording: %s", err)
71 mod.recording = false
72 break
73 }
74 }
75 }
76
77 mod.Info("stopped recording to %s ...", mod.recordFileName)
78}
79
80func (mod *RestAPI) startRecording(filename string) (err error) {
81 if mod.recording {

Callers 1

startRecordingMethod · 0.95

Calls 4

recordStateMethod · 0.95
InfoMethod · 0.45
AddMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected