Skip to content

Commit b7eef8d

Browse files
fix: size limit message visible in quiet/enterprise mode
The 'Reached data size limit' message was written via log.Progress() which is suppressed in quiet mode (enterprise default). This caused Step 21 of the integration tests to fail — the test looks for this message in the binary output but couldn't find it. Fix: Add Logger.Warn() that always prints regardless of quiet mode (like Error but with [warning] tag). Use Warn for size limit messages since they're important operational signals that should always be visible.
1 parent 2f8bf3a commit b7eef8d

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

internal/detector/nodescan.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,8 @@ func (s *NodeScanner) ScanProjects(ctx context.Context, searchDirs []string) []m
285285
break
286286
}
287287
if totalSize > maxBytes {
288-
s.log.Progress(" Reached data size limit (%d bytes collected, limit: %d bytes)", totalSize, maxBytes)
289-
s.log.Progress(" Skipping remaining projects (prioritized by most recently modified)")
288+
s.log.Warn("Reached data size limit (%d bytes collected, limit: %d bytes)", totalSize, maxBytes)
289+
s.log.Warn("Skipping remaining projects (prioritized by most recently modified)")
290290
break
291291
}
292292

@@ -298,8 +298,8 @@ func (s *NodeScanner) ScanProjects(ctx context.Context, searchDirs []string) []m
298298
resultSize := int64(len(r.RawStdoutBase64)) + int64(len(r.RawStderrBase64))
299299

300300
if totalSize+resultSize > maxBytes {
301-
s.log.Progress(" Reached data size limit (%d bytes collected, limit: %d bytes)", totalSize, maxBytes)
302-
s.log.Progress(" Skipping remaining projects (prioritized by most recently modified)")
301+
s.log.Warn("Reached data size limit (%d bytes collected, limit: %d bytes)", totalSize, maxBytes)
302+
s.log.Warn("Skipping remaining projects (prioritized by most recently modified)")
303303
break
304304
}
305305

internal/progress/progress.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ func (l *Logger) Progress(format string, args ...any) {
4040
fmt.Fprintf(os.Stderr, "\033[2m%s [scanning]\033[0m %s\n", ts, fmt.Sprintf(format, args...))
4141
}
4242

43+
// Warn always prints to stderr regardless of quiet mode.
44+
// Use for important operational messages that should be visible even in enterprise (quiet) mode.
45+
func (l *Logger) Warn(format string, args ...any) {
46+
ts := time.Now().Format("2006-01-02 15:04:05")
47+
fmt.Fprintf(os.Stderr, "%s \033[0;33m[warning]\033[0m %s\n", ts, fmt.Sprintf(format, args...))
48+
}
49+
4350
// Error always prints to stderr regardless of quiet mode.
4451
// Format: [error] message
4552
func (l *Logger) Error(format string, args ...any) {

0 commit comments

Comments
 (0)