Take control over your live stream video by running it yourself. Streaming + chat out of the box.
HTML activitypubbroadcastingchatdecentralizedfederationfediversegolanghacktoberfesthlslivelivestreamowncastrtmpself-hostedstreaming-videovideo
Limit number of log entries returned. Closes #423
Gabe Kangas36377009d366
diff --git a/controllers/admin/logs.go b/controllers/admin/logs.goindex b7657111b7..bd16051bce 100644--- a/controllers/admin/logs.go+++ b/controllers/admin/logs.go@@ -32,7 +32,10 @@ func GetWarnings(w http.ResponseWriter, r *http.Request) {response := make([]logsResponse, 0)for i := 0; i < len(logs); i++ {- response = append(response, fromEntry(logs[i]))+ logEntry := logs[i]+ if logEntry != nil {+ response = append(response, fromEntry(logEntry))+ }}w.Header().Set("Content-Type", "application/json")diff --git a/logging/logging.go b/logging/logging.goindex 5dfe05abf2..2d1ccdc0b1 100644--- a/logging/logging.go+++ b/logging/logging.go@@ -4,6 +4,7 @@ package logging// Modeled after https://github.com/sirupsen/logrus/blob/master/hooks/test/test.goimport (+ "math""os""sync"@@ -53,11 +54,13 @@ func (l *OCLogger) Levels() []logrus.Level {func (l *OCLogger) AllEntries() []*logrus.Entry {l.mu.RLock()defer l.mu.RUnlock()+// Make a copy so the returned value won't race with future log requests- entries := make([]*logrus.Entry, len(l.Entries))- for i := 0; i < len(l.Entries); i++ {+ logCount := int(math.Min(float64(len(l.Entries)), 800.0))+ entries := make([]*logrus.Entry, logCount)+ for i := 0; i < len(entries); i++ {// Make a copy, for safety- entries[i] = &l.Entries[i]+ entries[len(entries)-logCount:][i] = &l.Entries[i]}return entries@@ -67,12 +70,14 @@ func (l *OCLogger) AllEntries() []*logrus.Entry {func (l *OCLogger) WarningEntries() []*logrus.Entry {l.mu.RLock()defer l.mu.RUnlock()+// Make a copy so the returned value won't race with future log requests- entries := make([]*logrus.Entry, 0)- for i := 0; i < len(l.Entries); i++ {+ logCount := int(math.Min(float64(len(l.Entries)), 100.0))+ entries := make([]*logrus.Entry, logCount)+ for i := 0; i < len(entries); i++ {if l.Entries[i].Level <= logrus.WarnLevel {// Make a copy, for safety- entries = append(entries, &l.Entries[i])+ entries[len(entries)-logCount:][i] = &l.Entries[i]}}