Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ACS
Public
Cloud
MAS
clonemap
Commits
4fbe289c
Commit
4fbe289c
authored
Mar 31, 2021
by
Stefan Dähling
Browse files
get logs by time
parent
175b120d
Pipeline
#438332
passed with stages
in 9 minutes and 20 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
pkg/logger/handler.go
View file @
4fbe289c
...
...
@@ -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
)
...
...
pkg/logger/storage.go
View file @
4fbe289c
...
...
@@ -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
st
art
.
After
(
stor
.
mas
[
masID
]
.
agents
[
agentID
]
.
statLogs
[
i
]
.
Timestamp
)
return
st
or
.
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
])
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment