Commit 4fbe289c authored by Stefan Dähling's avatar Stefan Dähling
Browse files

get logs by time

parent 175b120d
Pipeline #438332 passed with stages
in 9 minutes and 20 seconds
......@@ -211,13 +211,14 @@ func (logger *Logger) handleGetLogsTime(w http.ResponseWriter, r *http.Request)
}
vars := mux.Vars(r)
topic := vars["topic"]
start, cmapErr := time.Parse(time.RFC3339, vars["start"])
// start, cmapErr := time.Parse(time.RFC3339, vars["start"])
start, cmapErr := time.Parse("20060102150405", vars["start"])
if cmapErr != nil {
httpErr = httpreply.NotFoundError(w)
logger.logErrors(r.URL.Path, cmapErr, httpErr)
return
}
end, cmapErr := time.Parse(time.RFC3339, vars["end"])
end, cmapErr := time.Parse("20060102150405", vars["end"])
if cmapErr != nil {
httpErr = httpreply.NotFoundError(w)
logger.logErrors(r.URL.Path, cmapErr, httpErr)
......
......@@ -213,13 +213,13 @@ func (stor *localStorage) getAgentLogMessagesInRange(masID int, agentID int, top
if length > 0 {
startIndex := sort.Search(length,
func(i int) bool {
return start.After(stor.mas[masID].agents[agentID].errLogs[i].Timestamp)
return stor.mas[masID].agents[agentID].errLogs[i].Timestamp.After(start)
})
endIndex := sort.Search(length,
func(i int) bool {
return end.After(stor.mas[masID].agents[agentID].errLogs[i].Timestamp)
return stor.mas[masID].agents[agentID].errLogs[i].Timestamp.After(end)
})
if endIndex >= 0 {
if endIndex-startIndex >= 0 {
logs = make([]schemas.LogMessage, endIndex-startIndex, endIndex-startIndex)
copy(logs, stor.mas[masID].agents[agentID].errLogs[startIndex:endIndex])
}
......@@ -229,13 +229,13 @@ func (stor *localStorage) getAgentLogMessagesInRange(masID int, agentID int, top
if length > 0 {
startIndex := sort.Search(length,
func(i int) bool {
return start.After(stor.mas[masID].agents[agentID].dbgLogs[i].Timestamp)
return stor.mas[masID].agents[agentID].dbgLogs[i].Timestamp.After(start)
})
endIndex := sort.Search(length,
func(i int) bool {
return end.After(stor.mas[masID].agents[agentID].dbgLogs[i].Timestamp)
return stor.mas[masID].agents[agentID].dbgLogs[i].Timestamp.After(end)
})
if endIndex >= 0 {
if endIndex-startIndex >= 0 {
logs = make([]schemas.LogMessage, endIndex-startIndex, endIndex-startIndex)
copy(logs, stor.mas[masID].agents[agentID].dbgLogs[startIndex:endIndex])
}
......@@ -245,13 +245,13 @@ func (stor *localStorage) getAgentLogMessagesInRange(masID int, agentID int, top
if length > 0 {
startIndex := sort.Search(length,
func(i int) bool {
return start.After(stor.mas[masID].agents[agentID].msgLogs[i].Timestamp)
return stor.mas[masID].agents[agentID].msgLogs[i].Timestamp.After(start)
})
endIndex := sort.Search(length,
func(i int) bool {
return end.After(stor.mas[masID].agents[agentID].msgLogs[i].Timestamp)
return stor.mas[masID].agents[agentID].msgLogs[i].Timestamp.After(end)
})
if endIndex >= 0 {
if endIndex-startIndex >= 0 {
logs = make([]schemas.LogMessage, endIndex-startIndex, endIndex-startIndex)
copy(logs, stor.mas[masID].agents[agentID].msgLogs[startIndex:endIndex])
}
......@@ -261,14 +261,14 @@ func (stor *localStorage) getAgentLogMessagesInRange(masID int, agentID int, top
if length > 0 {
startIndex := sort.Search(length,
func(i int) bool {
return start.After(
stor.mas[masID].agents[agentID].statLogs[i].Timestamp)
return stor.mas[masID].agents[agentID].statLogs[i].Timestamp.
After(start)
})
endIndex := sort.Search(length,
func(i int) bool {
return end.After(stor.mas[masID].agents[agentID].statLogs[i].Timestamp)
return stor.mas[masID].agents[agentID].statLogs[i].Timestamp.After(end)
})
if endIndex >= 0 {
if endIndex-startIndex >= 0 {
logs = make([]schemas.LogMessage, endIndex-startIndex, endIndex-startIndex)
copy(logs, stor.mas[masID].agents[agentID].statLogs[startIndex:endIndex])
}
......@@ -284,7 +284,7 @@ func (stor *localStorage) getAgentLogMessagesInRange(masID int, agentID int, top
func(i int) bool {
return stor.mas[masID].agents[agentID].appLogs[i].Timestamp.After(end)
})
if endIndex >= 0 {
if endIndex-startIndex >= 0 {
logs = make([]schemas.LogMessage, endIndex-startIndex, endIndex-startIndex)
copy(logs, stor.mas[masID].agents[agentID].appLogs[startIndex:endIndex])
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment