Skip to content

Commit

Permalink
fix: log entries were not being loaded
Browse files Browse the repository at this point in the history
Broke in ec18c3c

Signed-off-by: Hiram Chirino <hiram@hiramchirino.com>
  • Loading branch information
chirino committed Sep 12, 2024
1 parent 7967282 commit 0ac6191
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion internal/pkg/source/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import (
"bufio"
"bytes"
"errors"
"github.com/hedhyw/semerr/pkg/v1/semerr"
"io"
"os"

"github.com/hedhyw/semerr/pkg/v1/semerr"

"github.com/hedhyw/json-log-viewer/internal/pkg/config"
)

Expand Down
6 changes: 3 additions & 3 deletions internal/pkg/source/sreamer.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func (is *Source) StartStreaming(ctx context.Context, send func(msg LazyLogEntri
eofEvent := make(chan struct{}, 1)

// Load log entries async..
go is.readLogEntries(ctx, send, &logEntriesLock, logEntries, eofEvent)
go is.readLogEntries(ctx, send, &logEntriesLock, &logEntries, eofEvent)

// periodically send new log entries to the program.
go func() {
Expand Down Expand Up @@ -57,7 +57,7 @@ func (is *Source) StartStreaming(ctx context.Context, send func(msg LazyLogEntri
}()
}

func (is *Source) readLogEntries(ctx context.Context, send func(msg LazyLogEntries, err error), logEntriesLock *sync.Mutex, logEntries []LazyLogEntry, eofEvent chan struct{}) {
func (is *Source) readLogEntries(ctx context.Context, send func(msg LazyLogEntries, err error), logEntriesLock *sync.Mutex, logEntries *[]LazyLogEntry, eofEvent chan struct{}) {
defer func() {
eofEvent <- struct{}{}
}()
Expand Down Expand Up @@ -93,7 +93,7 @@ func (is *Source) readLogEntries(ctx context.Context, send func(msg LazyLogEntri
return
}
logEntriesLock.Lock()
logEntries = append(logEntries, entry)
*logEntries = append(*logEntries, entry)
logEntriesLock.Unlock()
}
}

0 comments on commit 0ac6191

Please sign in to comment.