Skip to content

Commit 9841b04

Browse files
add debug logs
1 parent 4cf5861 commit 9841b04

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

trickle/local_publisher.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ func (c *TrickleLocalPublisher) Write(data io.Reader) error {
5555
totalRead := 0
5656
for {
5757
n, err := data.Read(buf)
58+
slog.Info("Reading published data", "channel", c.channelName, "seq", seq, "bytes read", n, "err", err)
5859
if n > 0 {
5960
segment.writeData(buf[:n])
6061
totalRead += n

trickle/trickle_publisher.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"io"
88
"log/slog"
99
"net/http"
10+
"strings"
1011
"sync"
1112
)
1213

@@ -213,7 +214,9 @@ func (p *pendingPost) Write(data io.Reader) (int64, error) {
213214

214215
// Start streaming data to the current POST request
215216
n, ioError := io.Copy(writer, data)
216-
217+
if strings.Contains(p.client.baseURL, "control") {
218+
slog.Info("Streaming data to segment", "index", index, "bytes written", n, "ioError", ioError)
219+
}
217220
// if no io errors, close the writer
218221
var closeErr error
219222
if ioError == nil {

trickle/trickle_server.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,10 @@ func (s *Stream) handlePost(w http.ResponseWriter, r *http.Request, idx int) {
390390
totalRead := 0
391391
for {
392392
n, err := reader.Read(buf)
393+
if strings.Contains(s.name, "control") {
394+
slog.Info("Reading POST body", "stream", s.name, "idx", idx, "bytes read", n, "err", err)
395+
}
396+
393397
if n > 0 {
394398
if totalRead == 0 {
395399
s.mutex.Lock()
@@ -546,6 +550,9 @@ func (s *Stream) handleGet(w http.ResponseWriter, r *http.Request, idx int) {
546550
}
547551

548552
data, eof := subscriber.readData()
553+
if strings.Contains(s.name, "control") {
554+
slog.Info("Sending data to client", "stream", s.name, "idx", segment.idx, "dataLen", len(data), "eof", eof)
555+
}
549556
if len(data) > 0 {
550557
if totalWrites <= 0 {
551558
if segment.idx != latestSeq {

0 commit comments

Comments
 (0)