Skip to content

Commit 47121f4

Browse files
committed
WIP
1 parent 7829ef2 commit 47121f4

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

input/system/planetscale/logs.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ func DownloadLogFiles(ctx context.Context, server *state.Server, logger *util.Lo
197197
var newestTimestamp time.Time
198198
var sizeLimitReached bool
199199
since := psl.PlanetScale.LastTimestamp
200+
// Initialize since to 2 minutes ago
200201

201202
for {
202203
logReader, err := QueryLogs(
@@ -217,7 +218,7 @@ func DownloadLogFiles(ctx context.Context, server *state.Server, logger *util.Lo
217218

218219
count := 0
219220
for {
220-
entry, err := logReader.Read()
221+
msg, err := logReader.ReadString('\n')
221222
if err == io.EOF {
222223
break
223224
}
@@ -226,11 +227,6 @@ func DownloadLogFiles(ctx context.Context, server *state.Server, logger *util.Lo
226227
return psl, nil, nil, fmt.Errorf("failed to read log entry: %w", err)
227228
}
228229

229-
msg := entry.Msg
230-
if !strings.HasSuffix(msg, "\n") {
231-
msg += "\n"
232-
}
233-
234230
newContent := []byte(msg)
235231
if len(newContent) > maxLogParsingSize {
236232
content = newContent[len(newContent)-maxLogParsingSize:]
@@ -239,7 +235,7 @@ func DownloadLogFiles(ctx context.Context, server *state.Server, logger *util.Lo
239235
if overflow > 0 {
240236
if !sizeLimitReached {
241237
sizeLimitReached = true
242-
logger.PrintWarning("PlanetScale: Log data exceeds %d bytes, discarding older data", maxLogParsingSize)
238+
logger.PrintWarning("PlanetScale: Log data exceeds %d MB in interval, discarding older data", maxLogParsingSize / 1024 / 1024)
243239
}
244240
content = content[overflow:]
245241
}

logs/parse.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ func ParseAndAnalyzeBuffer(logStream LineReader, linesNewerThan time.Time, serve
461461

462462
// Ignore loglines which are outside our time window
463463
if logLine.OccurredAt.Before(linesNewerThan) {
464-
// if very verbose emit a warning here
464+
//fmt.Printf("Skipping line because its outside the specified time window (%s < %s)", logLine.OccurredAt, linesNewerThan)
465465
continue
466466
}
467467

0 commit comments

Comments
 (0)