未验证 提交 5abc111d 编写于 作者: D DongGang 提交者: GitHub

fix(code-style): polish the logs/logs.go (#5071)

* fix(code-style): polish the logs/logs.go

1. private method statement use lower case
2. remove the meaningless bracket
...
Signed-off-by: NDong Gang <dong.gang@daocloud.io>

* Correct the comment
上级 a016ffd4
......@@ -19,8 +19,8 @@ import (
"strings"
)
// LINE_INDEX_NOT_FOUND is returned if requested line could not be found
var LINE_INDEX_NOT_FOUND = -1
// LineIndexNotFound is returned if requested line could not be found
var LineIndexNotFound = -1
// DefaultDisplayNumLogLines returns default number of lines in case of invalid request.
var DefaultDisplayNumLogLines = 100
......@@ -154,7 +154,7 @@ type LogTimestamp string
func (self LogLines) SelectLogs(logSelection *Selection) (LogLines, LogTimestamp, LogTimestamp, Selection, bool) {
requestedNumItems := logSelection.OffsetTo - logSelection.OffsetFrom
referenceLineIndex := self.getLineIndex(&logSelection.ReferencePoint)
if referenceLineIndex == LINE_INDEX_NOT_FOUND || requestedNumItems <= 0 || len(self) == 0 {
if referenceLineIndex == LineIndexNotFound || requestedNumItems <= 0 || len(self) == 0 {
// Requested reference line could not be found, probably it's already gone or requested no logs. Return no logs.
return LogLines{}, "", "", Selection{}, false
}
......@@ -216,10 +216,10 @@ func (self LogLines) getLineIndex(logLineId *LogLineId) int {
if 0 <= offset && offset < linesMatched {
return matchingStartedAt + offset
}
return LINE_INDEX_NOT_FOUND
return LineIndexNotFound
}
// CreateLogLineId returns ID of the line with provided lineIndex.
// createLogLineId returns ID of the line with provided lineIndex.
func (self LogLines) createLogLineId(lineIndex int) *LogLineId {
logTimestamp := self[lineIndex].Timestamp
// determine whether to use negative or positive indexing
......@@ -235,7 +235,7 @@ func (self LogLines) createLogLineId(lineIndex int) *LogLineId {
}
offset := step
for ; 0 <= lineIndex-offset && lineIndex-offset < len(self); offset += step {
if !(self[lineIndex-offset].Timestamp == logTimestamp) {
if self[lineIndex-offset].Timestamp != logTimestamp {
break
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册