Skip to content

Commit

Permalink
Merge pull request docker#98 from aaronlehmann/logs-padding-underflow
Browse files Browse the repository at this point in the history
service: Avoid underflow in logs padding calculation
  • Loading branch information
thaJeztah authored May 16, 2017
2 parents 37bf8ff + ab6bc5d commit ebbab14
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions cli/command/service/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,12 @@ func (f *taskFormatter) format(ctx context.Context, logCtx logContext) (string,
}
}

padding := strings.Repeat(" ", f.padding-getMaxLength(task.Slot))
formatted := fmt.Sprintf("%s@%s%s", taskName, nodeName, padding)
paddingCount := f.padding - getMaxLength(task.Slot)
padding := ""
if paddingCount > 0 {
padding = strings.Repeat(" ", paddingCount)
}
formatted := taskName + "@" + nodeName + padding
f.cache[logCtx] = formatted
return formatted, nil
}
Expand Down

0 comments on commit ebbab14

Please sign in to comment.