in util/common/logs.go [83:113]
func writeToLogs(filePath string, duration, sendingInterval time.Duration, logLinesPerMinute int) error {
f, err := os.Create(filePath)
if err != nil {
return err
}
defer f.Close()
defer os.Remove(filePath)
ticker := time.NewTicker(sendingInterval)
defer ticker.Stop()
endTimeout := time.After(duration)
// Sending the logs within the first minute before the ticker kicks in the next minute
for i := 0; i < logLinesPerMinute; i++ {
_, err := f.WriteString(fmt.Sprintf(logLine, i))
if err != nil {
return err
}
}
for {
select {
case <-ticker.C:
for i := 0; i < logLinesPerMinute; i++ {
f.WriteString(fmt.Sprintf(logLine, i))
}
case <-endTimeout:
return nil
}
}
}