refactor: tidy up
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user