Skip to content

Commit

Permalink
roachtest: mixedversion: sanitize both log path and prefix
Browse files Browse the repository at this point in the history
Avoiding filenames with spaces on them is generally a good idea.

Epic: none

Release note: None
  • Loading branch information
renatolabs committed Sep 26, 2024
1 parent 7761c2f commit 72c8c7e
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions pkg/cmd/roachtest/roachtestutil/mixedversion/mixedversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -1064,16 +1064,15 @@ func newSingleStep(context *Context, impl singleStepProtocol, rng *rand.Rand) *s
// prefixedLogger returns a logger instance off of the given `l`
// parameter. The path and prefix are the same.
func prefixedLogger(l *logger.Logger, prefix string) (*logger.Logger, error) {
filename := sanitizePath(prefix)
return prefixedLoggerWithFilename(l, filename, filename)
return prefixedLoggerWithFilename(l, prefix, prefix)
}

// prefixedLoggerWithFilename returns a logger instance with the given
// prefix. The logger will write to a file on the given `path`,
// relative to the logger `l`'s location.
func prefixedLoggerWithFilename(l *logger.Logger, prefix, path string) (*logger.Logger, error) {
formattedPrefix := fmt.Sprintf("[%s] ", prefix)
return l.ChildLogger(path, logger.LogPrefix(formattedPrefix))
formattedPrefix := fmt.Sprintf("[%s] ", sanitizePath(prefix))
return l.ChildLogger(sanitizePath(path), logger.LogPrefix(formattedPrefix))
}

func sanitizePath(s string) string {
Expand Down

0 comments on commit 72c8c7e

Please sign in to comment.