refactor: tidy up
This commit is contained in:
-1
Submodule godump deleted from 9a417155fc
@@ -61,19 +61,9 @@ func Init(broadcast func(string, interface{})) {
|
|||||||
Broadcast = broadcast
|
Broadcast = broadcast
|
||||||
ringBuffer = ring.New(100)
|
ringBuffer = ring.New(100)
|
||||||
log.SetOutput(&customWriter{stdout: os.Stdout})
|
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)
|
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 {
|
func GetRecentLogs() []LogEntry {
|
||||||
bufferMu.Lock()
|
bufferMu.Lock()
|
||||||
defer bufferMu.Unlock()
|
defer bufferMu.Unlock()
|
||||||
|
|||||||
@@ -197,10 +197,6 @@ func (m *Manager) runEncoder(job db.Job) error {
|
|||||||
|
|
||||||
scanner := bufio.NewScanner(stderr)
|
scanner := bufio.NewScanner(stderr)
|
||||||
scanner.Split(bufio.ScanLines)
|
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) {
|
scanner.Split(func(data []byte, atEOF bool) (advance int, token []byte, err error) {
|
||||||
if atEOF && len(data) == 0 {
|
if atEOF && len(data) == 0 {
|
||||||
return 0, nil, nil
|
return 0, nil, nil
|
||||||
|
|||||||
Reference in New Issue
Block a user