refactor: tidy up

This commit is contained in:
2026-06-08 18:21:27 +01:00
parent ef649e50a2
commit b7585528d1
3 changed files with 0 additions and 15 deletions
-10
View File
@@ -61,19 +61,9 @@ func Init(broadcast func(string, interface{})) {
Broadcast = broadcast
ringBuffer = ring.New(100)
log.SetOutput(&customWriter{stdout: os.Stdout})
// Remove timestamp from log format since we add it in LogEntry or we can let log package add it
// Wait, standard log adds timestamp. If standard log adds timestamp, our `msg` will contain the timestamp.
// But `LogEntry` has a `Timestamp` field for the JSON.
// It's cleaner to remove the standard log flags so `msg` is just the message, and let stdout print the plain msg?
// But stdout wouldn't have timestamps then unless we format it ourselves.
// Let's just remove log flags and format it ourselves for stdout!
log.SetFlags(0)
}
// Since we removed log flags, we need to handle stdout formatting in Write if we want timestamps in stdout.
// Actually, let's keep the timestamp in stdout, we can modify customWriter.Write to prepend the timestamp to stdout.
// We'll update the writer in a moment if needed.
func GetRecentLogs() []LogEntry {
bufferMu.Lock()
defer bufferMu.Unlock()
-4
View File
@@ -197,10 +197,6 @@ func (m *Manager) runEncoder(job db.Job) error {
scanner := bufio.NewScanner(stderr)
scanner.Split(bufio.ScanLines)
// Some ffmpeg progress output uses carriage returns instead of newlines
// We handle standard lines, to get a more robust carriage return split, we could implement a custom split function.
// For simplicity, ScanLines usually catches 'time=' lines well enough if they have \n.
// Let's use a custom split to handle '\r' as well.
scanner.Split(func(data []byte, atEOF bool) (advance int, token []byte, err error) {
if atEOF && len(data) == 0 {
return 0, nil, nil